rstan icon indicating copy to clipboard operation
rstan copied to clipboard

BFMI is inconsistent with the paper

Open sethaxen opened this issue 6 years ago • 1 comments

Summary:

The BFMI implementation is inconsistent with the original paper.

Description:

The numerator in get_bfmi is divided by the length of x https://github.com/stan-dev/rstan/blob/f79dae16e3bc187601520a165916b4d39d83af8d/rstan/rstan/R/check_hmc_diagnostics.R#L231 This is consistent with the paper's equation (bottom of page 7) if var gives the maximum likelihood estimate, but it gives the unbiased estimator instead. The resulting BFMI is off by a factor of (length(x) - 1) / length(x)

PyStan's implementation agrees with the paper (numpy.var defaults to the maximum likelihood estimate).

sethaxen avatar Nov 04 '19 23:11 sethaxen

Noticed something off about this today too so I'm seconding this observation! Shouldn't it be mean(diff(energy) ^ 2) / var(energy)?

tjmahr avatar May 02 '25 17:05 tjmahr