stan-dev / stan

Stan development repository. The master branch contains the current release. The develop branch contains the latest stable development. See the Developer Process Wiki for details.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
2.59k stars 370 forks source link

ADVI diagnostic #2474

Open avehtari opened 6 years ago

avehtari commented 6 years ago

Summary:

Add PSIS diagnostic for ADVI .

Description:

This paper proposes PSIS diagnostic for ADVI: Yuling Yao, Aki Vehtari, Daniel Simpson, and Andrew Gelman (2018). Yes, but Did It Work?: Evaluating Variational Inference https://arxiv.org/abs/1802.02538

Currently ADVI samples N draws from the approximate distribution and outputs those. In addition lp column is inserted, but it has all 0's (it seems stansummary requires lp column).

To follow the current design with stansummary, what we propose is

Note that initially we start just computing the diagnostics, but eventually we can use diagnostics to improve the algorithm.

avehtari commented 6 years ago

@yao-yl is working on this, but I can't assign this issue for him

yao-yl commented 6 years ago

I do not know why I cannot get assigned or self-assigned. But yes, I am working on this. I have implemented this in cmdstan and will try to add it in rstan.

bob-carpenter commented 6 years ago

I think you need to be added as a collaborator to be assigned---I think @syclik and @seantalts have the permissions to do that for you.

seantalts commented 6 years ago

Weird! I'll look into it.

drezap commented 5 years ago

@yao-yl I was thinking about assigning myself, but it appears you've already implemented this:

I have implemented this in cmdstan

We can do separate PR's for each interface.

Want to drop me the code and I can go ahead and integrate it and write appropriate tests?

avehtari commented 5 years ago

I just updated the issue. 2 first things are in Stan. Next thing would be to implement khat and n_eff in services.

drezap commented 5 years ago

To compute khat I'm using Zhang and Stephens section 4?

bob-carpenter commented 5 years ago

The reference I know for ADVI eval with k-hat is Yao et al..

avehtari commented 5 years ago

You can use the R code as a reference implementation https://github.com/stan-dev/loo/blob/master/R/gpdfit.R It follows Zhang and Stephens , but uses numerically more stable computations plus weakly informative prior.

drezap commented 5 years ago

and then for Neff?

avehtari commented 5 years ago

For Neff see the variance formula which is last equation on page 4 in https://arxiv.org/abs/1507.02646 and for the reference code see https://github.com/stan-dev/rstan/blob/develop/rstan/rstan/R/stanmodel-class.R#L288 lines 288-304