Evaluating Variational Inference: Does rstan expose VI approx density?

Hi all,

I am exploring ADVI and in this regard I wanted to use the PSIS diagnostic introduced by @yuling, @avehtari et al. in Yes, but did it work?: Evaluating variational inference.

Using their notation of algorithm 1, I was wondering whether there is a method / object that allows me to access the fitted (log) VI approximation density for the samples, that is q(\theta_s)? Or did you guys manually write a function for the log of the, say, mean field VI density at fitted parameters?

Cheers!

@yuling has a branch for CmdStan


This adds log q to the csv output.

I hope we can get the diagnostics in CmdStan develop branch and in Rstan in next couple weeks (and before StanCon Helsinki).

Has this been added to CmdStan 2.18. in the meantime?

Another related question: Is the PSIS diagnostic applicable for variational approximations when working with right censored data and a corresponding likelihood?

2.18 has already been tagged, and it’s not in there. Maybe in 2.19 @yuling?

PSIS diagnostic for VI and ADVI do not know anything about likelihood, they have access only to the joint log density (target).

No

It would be very handy to have code for this in R, too, given a stanfit-class object that gets returned by vb. If I wanted to code this, do I have all the ingredients available/exposed through rstan (e.g. the mean and standard deviation of each Gaussian factor)?

No. The (co)variance(s) of VB does not get returned in the stanfit object currently.