bm: Perform consistent batch means estimation on a vector of...

Description Usage Arguments Value References See Also Examples

View source: R/batchmeans.R

Description

Perform consistent batch means estimation on a vector of values from a Markov chain.

Usage

1
bm(x, size = "sqroot", warn = FALSE)

Arguments

x

a vector of values from a Markov chain.

size

the batch size. The default value is “sqroot”, which uses the square root of the sample size. “cuberoot” will cause the function to use the cube root of the sample size. A numeric value may be provided if neither “sqroot” nor “cuberoot” is satisfactory.

warn

a logical value indicating whether the function should issue a warning if the sample size is too small (less than 1,000).

Value

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.

References

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.

See Also

bmmat, which applies bm to each column of a matrix or data frame.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 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)

batchmeans documentation built on July 2, 2020, 4:15 a.m.

Related to bm in batchmeans...