neff: Correct Markov chain sample count for autocorrelation.

Description Usage Arguments Details Value Note

View source: R/util.R

Description

The output of a Markov chain sampling process is autocorrelated; therefore, the effective number of samples is less than the actual number of samples collected. This function computes the corrected value.

Usage

1
neff(samps)

Arguments

samps

Matrix of samples, with samples in rows and variables in columns

Details

This function is currently just a thin wrapper around effectiveSize. As noted below, the method used in this calculation is not ideal, so eventually we will replace this with something more sophisticated.

Value

Vector of N_e values, one for each variable

Note

The effective sample size is computed as

N_e = \frac{N}{1+2∑_{k=1}^∞} ρ(k),

where ρ(k) is the autocorrelation at lag k. We calculate this independently for each sampled variable and return the result as a vector. Generally, if these values differ greatly, you will want the smallest value reported.

Andrew Gelman makes the following observation about this calculation:

“[This definition] for effective sample size doesn’t quite work in practice because (a) you can’t sum to infinity, and (b) it will be too optimistic for chains that haven’t mixed. We have an effective sample size estimate that addresses both these concerns. It’s in formulas (11.7) and (11.8) in Section 11.5 of BDA3.

If you don’t have a copy of BDA, it’s also in the Stan manual, on pages 353-354 of the manual for Stan version 2.14.0.” (https://www.johndcook.com/blog/2017/06/27/effective-sample-size-for-mcmc/#comment-933045)

We have gone with the simpler definition for now, since this package is mostly intended for light-duty work, but we should consider putting in the more sophisticated version at some point.


JGCRI/metrosamp documentation built on Aug. 8, 2019, 10:59 p.m.