bm {batchmeans} | R Documentation |
Perform consistent batch means estimation on a vector of values from a Markov chain.
bm(x, size = "sqroot", warn = FALSE)
x |
a vector of values from a Markov chain. |
size |
the batch size. The default value is “ |
warn |
a logical value indicating whether the function should issue a warning if the sample size is too small (less than 1,000). |
bm
returns a list with two elements:
est |
the mean of the vector. |
se |
the MCMC standard error based on the consistent batch means estimator. |
Jones, G. L., Haran, M., Caffo, B. S. and Neath, R. (2006) Fixed-width output analysis for Markov chain Monte Carlo. Journal of the American Statistical Association, 101, 1537–1547.
The following article is less technical and contains a direct comparison to the Gelman-Rubin diagnostic.
Flegal, J. M., Haran, M. and Jones, G. L. (2008) Markov chain Monte Carlo: Can we trust the third significant figure? Statistical Science, 23, 250–260.
bmmat
, which applies bm
to each column of a matrix or data frame.
# Simulate a sample path of length 10,000 for an AR(1) chain with rho equal to 0.7. X = numeric(10000) X[1] = 1 for (i in 1:9999) X[i + 1] = 0.7 * X[i] + rnorm(1) # Estimate the mean and MCSE. bm(X)