stan-dev / stan-dev/rstan

BFMI is inconsistent with the paper

Open
#712 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
1.1k
Forks
266
Avg merge
2h 56m
Merged PRs (30d)
1

Description

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).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in rstan/R/check_hmc_diagnostics.R at get_bfmi, then compare its variance calculation with the equation on page 7 of the linked paper and the referenced PyStan implementation. Done means BFMI uses the estimator specified by the paper and no longer differs by the reported length-dependent factor.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.