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

mcse.multi

Multivariate Monte Carlo standard errors for expectations.


Description

Function returns the estimate of the covariance matrix in the Markov Chain CLT using batch means or spectral variance methods (with different lag windows). The function also returns the Monte Carlo estimate.

Usage

mcse.multi(x, method = "bm", r = 3, size = NULL, 
	g = NULL, adjust = TRUE, blather = FALSE)

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 overlapping batch means estimator with, ``bartlett'' and ``tukey'' represents the modified-Bartlett window and the Tukey-Hanning windows for spectral variance estimators.

r

the lugsail parameter that converts a lag window into its lugsail equivalent. Larger values of ``r'' will typically imply less underestimation of ``cov'', but higher variability of the estimator. Default is ``r = 3'' and ``r = 1,2'' are good choices. ``r > 5'' is not recommended. Non-integer values are ok.

size

represents the batch size in “bm” and the truncation point in “bartlett” and “tukey”. Default is NULL which implies that an optimal batch size is calculated using the batchSize() function. Can take character values of ``sqroot'' and ``cuberoot'' or any numeric value between 1 and n/2. ``sqroot'' means size is floor(n^(1/2)) and “cuberoot” means size is floor(n^(1/3)).

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.

adjust

Defaults to TRUE. logical for whether the matrix should automatically be adjusted if unstable

blather

if TRUE, returns under-the-hood workings of the package

Value

A list is returned with the following components,

cov

a covariance matrix estimate.

est

estimate of g(x).

nsim

number of rows of the input x.

method

method used to calculate matrix cov.

size

value of size used to calculate cov.

adjust.used

whether an adjustment was used to calculate cov.

References

Vats, D., Flegal, J. M., and, Jones, G. L (2019) Multivariate Output Analysis for Markov chain Monte Carlo, Biometrika.

Vats, D., Flegal, J. M., and, Jones, G. L. (2018) Strong Consistency of multivariate spectral variance estimators for Markov chain Monte Carlo, Bernoulli.

See Also

batchSize, which computes an optimal batch size. mcse.initseq, which computes an initial sequence estimator. mcse, which acts on a vector. mcse.mat, which applies mcse to each column of a matrix or data frame. mcse.q and mcse.q.mat, which compute standard errors for quantiles.

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

mcse.bm <- mcse.multi(x = out)
mcse.tuk <- mcse.multi(x = out, method = "tukey")

# If we are only estimating the mean of the first component, 
# and the second moment of the second component

g <- function(x) return(c(x[1], x[2]^2))
mcse <- mcse.multi(x = out, g = g)

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.