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.
g
a function such that E(g(x)) is the
quantity of interest. The default is NULL, which
causes the identity function to be used.
method
the method used to compute the standard
error. This is one of “bm” (batch means,
the default), “obm” (overlapping batch
means), “tukey” (spectral variance method
with a Tukey-Hanning window), or “bartlett”
(spectral variance method with a Bartlett window).
warn
a logical value indicating whether the
function should issue a warning if the sample size is too
small (less than 1,000).
Value
mcse returns a list with two elements:
est
an estimate of E(g(x)).
se
the
Monte Carlo standard error.
References
Flegal, J. M. (2012) Applicability of subsampling
bootstrap methods in Markov chain Monte Carlo. In
Wozniakowski, H. and Plaskota, L., editors, Monte
Carlo and Quasi-Monte Carlo Methods 2010 (to appear).
Springer-Verlag.
Flegal, J. M. and Jones, G. L. (2010) Batch means and
spectral variance estimators in Markov chain Monte Carlo.
The Annals of Statistics, 38, 1034–1070.
Flegal, J. M. and Jones, G. L. (2011) Implementing Markov
chain Monte Carlo: Estimating with confidence. In Brooks,
S., Gelman, A., Jones, G. L., and Meng, X., editors,
Handbook of Markov Chain Monte Carlo, pages
175–197. Chapman & Hall/CRC Press.
Flegal, J. M., Jones, G. L., and Neath, R. (2012) Markov
chain Monte Carlo estimation of quantiles.
University of California, Riverside, Technical
Report.
Gong, L., and Flegal, J. M. A practical sequential stopping rule for high-dimensional Markov chain Monte Carlo. Journal of Computational and Graphical Statistics (to appear).
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.
Vats, D., Flegal, J. M., and, Jones, G. L Multivariate Output Analysis for Markov chain Monte Carlo, arXiv preprint arXiv:1512.07713 (2015).
See Also
mcse.mat, which applies mcse to each
column of a matrix or data frame.
mcse.multi, for a multivariate estimate of the Monte Carlo standard error.
mcse.q and mcse.q.mat, which
compute standard errors for quantiles.
Examples
# Create 10,000 iterations of an AR(1) Markov chain with rho = 0.9.
n = 10000
x = double(n)
x[1] = 2
for (i in 1:(n - 1))
x[i + 1] = 0.9 * x[i] + rnorm(1)
# Estimate the mean, 0.1 quantile, and 0.9 quantile with MCSEs using batch means.
mcse(x)
mcse.q(x, 0.1)
mcse.q(x, 0.9)
# Estimate the mean, 0.1 quantile, and 0.9 quantile with MCSEs using overlapping batch means.
mcse(x, method = "obm")
mcse.q(x, 0.1, method = "obm")
mcse.q(x, 0.9, method = "obm")
# Estimate E(x^2) with MCSE using spectral methods.
g = function(x) { x^2 }
mcse(x, g = g, method = "tukey")