neff: Effective sample size calculation

Description Usage Arguments Value References Examples

View source: R/mcmc_diag.R

Description

Calculates an estimate of the adjusted MCMC sample size per parameter adjusted for autocorrelation.

Usage

1
neff(object, burnin = NULL, lagmax = NULL, ...)

Arguments

object

an object of class hmclearn, usually a result of a call to mh or hmc

burnin

optional numeric parameter for the number of initial MCMC samples to omit from the summary

lagmax

maximum lag to extract for determining effective sample sizes

...

currently unused

Value

Numeric vector with effective sample sizes for each parameter in the model

References

Gelman, A., et. al. (2013) Bayesian Data Analysis. Chapman and Hall/CRC. Section 11.5

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# poisson regression example
set.seed(7363)
X <- cbind(1, matrix(rnorm(40), ncol=2))
betavals <- c(0.8, -0.5, 1.1)
lmu <- X %*% betavals
y <- sapply(exp(lmu), FUN = rpois, n=1)

f <- hmc(N = 1000,
          theta.init = rep(0, 3),
          epsilon = c(0.03, 0.02, 0.015),
          L = 10,
          logPOSTERIOR = poisson_posterior,
          glogPOSTERIOR = g_poisson_posterior,
          varnames = paste0("beta", 0:2),
          param = list(y=y, X=X),
          parallel=FALSE, chains=2)

neff(f, burnin=100)

hmclearn documentation built on Oct. 23, 2020, 8:04 p.m.