The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Version: 1.0-4
Date: 2020-05-07
Title: Consistent Batch Means Estimation of Monte Carlo Standard Errors
Author: Murali Haran <mharan@stat.psu.edu> and John Hughes <drjphughesjr@gmail.com>
Maintainer: John Hughes <drjphughesjr@gmail.com>
Depends: utils
Description: Provides consistent batch means estimation of Monte Carlo standard errors.
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
RoxygenNote: 5.0.1
NeedsCompilation: no
Packaged: 2020-05-07 14:07:01 UTC; jphughesjr
Repository: CRAN
Date/Publication: 2020-05-07 15:40:02 UTC

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

Description

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

Usage

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


# 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)

Apply bm to each column of a matrix or data frame of MCMC samples.

Description

Apply bm to each column of a matrix or data frame of MCMC samples.

Usage

bmmat(x)

Arguments

x

a matrix or data frame with each row being a draw from the multivariate distribution of interest.

Value

bmmat returns a matrix with ncol(x) rows and two columns. The row names of the matrix are the same as the column names of x. The column names of the matrix are “est” and “se”. The jth row of the matrix contains the result of applying bm to the jth column of x.

See Also

bm, which performs consistent batch means estimation for a vector.


Estimate effective sample size (ESS) as described in Kass et al. (1998) and Robert and Casella (2004; p. 500).

Description

Estimate effective sample size (ESS) as described in Kass et al. (1998) and Robert and Casella (2004; p. 500).

Usage

ess(x, imse = TRUE, verbose = FALSE)

Arguments

x

a vector of values from a Markov chain.

imse

logical. If TRUE, use an approach that is analogous to Geyer's initial monotone positive sequence estimator (IMSE), where correlations beyond a certain lag are removed to reduce noise.

verbose

logical. If TRUE and imse = TRUE, inform about the lag at which truncation occurs, and warn if the lag is probably too small.

Details

ESS is the size of an iid sample with the same variance as the current sample. ESS is given by

\mbox{ESS}=T/\eta,

where

\eta=1+2\sum \mbox{all lag autocorrelations}.

Value

The function returns the estimated effective sample size.

References

Kass, R. E., Carlin, B. P., Gelman, A., and Neal, R. (1998) Markov chain Monte Carlo in practice: A roundtable discussion. The American Statistician, 52, 93–100.

Robert, C. P. and Casella, G. (2004) Monte Carlo Statistical Methods. New York: Springer.

Geyer, C. J. (1992) Practical Markov chain Monte Carlo. Statistical Science, 7, 473–483.


Create a plot that shows how Monte Carlo estimates change with increasing sample size.

Description

Create a plot that shows how Monte Carlo estimates change with increasing sample size.

Usage

estvssamp(x, fun = mean, main = "Estimate vs Sample Size", add = FALSE,
  ...)

Arguments

x

a sample vector.

fun

a function such that E(fun(x)) is the quantity of interest. The default is fun = mean.

main

an overall title for the plot. The default is “Estimates vs Sample Size”.

add

logical. If TRUE, add to a current plot.

...

additional arguments to the plotting function.

Value

NULL

Examples


# 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)

# Plot MC estimates versus sample size.

estvssamp(X)

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.