Automatic Imputation of Multivariate models

We don’t have an API in place yet, but you can do it easy enough with a Potential

import pymc as pm
import numpy as np

import aesara.tensor as at

data = np.zeros((3,2))
data[[0, 1, 2, 2], [0, 1, 0, 1]] = np.nan
print(data)

with pm.Model() as m:
    # Create a vector of flat variables for the unobserved components of the MvNormal
    x_unobs = pm.Flat("x_unobs", shape=(np.isnan(data).sum(),))

    # Create the symbolic value of x, combining observed data and unobserved variables
    x = at.as_tensor(data)
    x = pm.Deterministic("x", at.set_subtensor(x[np.isnan(data)], x_unobs))

    # Add a Potential with the logp of the variable conditioned on `x`
    pm.Potential("x_logp", pm.logp(rv=pm.MvNormal.dist([0, 0], [[1,0],[0,1]]), value=x))
    idata = pm.sample()