I would like to implement the recently introduced PSIS diagnostics for evaluating variational inference in PyMC, in particular for ADVI. For the corresponding publication see Yes, but did it work?: Evaluating variational inference, in particular algorithm 1.
For this I need to extract the (log) of the density of the fitted VI approximation at a number of sampled points \theta (samples w.r.t. to the fitted VI approximation). Could you point me to an explanation on how to achieve this?
I also need to evaluate the (log) of the density function p(\theta, y), would that be achieved through logp?
Many thanks in advance, for reference here a snapshot of the algorithm.
Resulting noncentered_ADVI which you can just treat it as a trace object from PyMC3 that contains MCMC samples. Then you evaluate the model logp using each slice of the samples (we call it point) as input:
logp_func = NonCentered_eight.logp
for point in noncentered_ADVI:
p_theta_y.append(logp_func(point))
There is one more question concerning logp. I am new to Pymc3’s framework and this question may be silly. I see in your implementation in the notebook, logp(\theta, y), is evaluated using approx.model.logp(point), where \theta is the latent variables, y is the data and point here refers to \theta. However, I don’t see why it is not approx.model.logp(point ,y). Is this because y has been integrated into the model, when we set the observed variable and feed it by the observation?
It this is the case, how could we evaluate p(\theta, \hat{y}), where \hat{y} is not the original observation dataset?