Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

batchSize

Batch size (truncation point) selection


Description

Function returns the optimal batch size (or truncation point) for a given chain and method.

Usage

batchSize(x, method = "bm", g = NULL)

Arguments

x

a matrix or data frame of Markov chain output. Number of rows is the Monte Carlo sample size.

method

any of ``bm'', ``obm'', ``bartlett'', ``tukey''. ``bm'' represents batch means estimator, ``obm'' represents the overlapping batch means estimator, and ``bartlett'' and ``tukey'' represent the modified-Bartlett window and the Tukey-Hanning windows for the spectral variance estimators.

g

a function that represents features of interest. g is applied to each row of x and thus g should take a vector input only. If g is NULL, g is set to be identity, which is estimation of the mean of the target density.

Value

A value of the optimal batch size is returned.

References

Liu, Y., Vats, D., and Flegal, J. M. Batch size selection for variance estimators in MCMC, arXiv preprint arXiv:1804.05975 (2019).

See Also

mcse.multi, which calls on batchSize. mcse, which calls on batchSize.

Examples

library(mAr)
p <- 3
n <- 1e3
omega <- 5*diag(1,p)

## Making correlation matrix var(1) model
set.seed(100)
foo <- matrix(rnorm(p^2), nrow = p)
foo <- foo %*% t(foo)
phi <- foo / (max(eigen(foo)$values) + 1)
  
out <- as.matrix(mAr.sim(rep(0,p), phi, omega, N = n))

batchSize(out)
batchSize(out, method = "obm")
batchSize(out, method = "bartlett")

mcmcse

Monte Carlo Standard Errors for MCMC

v1.4-1
GPL (>= 2)
Authors
James M. Flegal <jflegal@ucr.edu>, John Hughes <j.hughes@ucdenver.edu>, Dootika Vats <dootika@iitk.ac.in>, and Ning Dai <daixx224@umn.edu>
Initial release
2020-01-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.