mcse.multi: Multivariate Monte Carlo standard errors for expectations.

Description Usage Arguments Value References See Also Examples

View source: R/mcse_multi.R

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

1
2
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 the overlapping batch means estimator, and “bartlett” and “tukey” represent the modified-Bartlett window and the Tukey-Hanning windows for the spectral variance estimators.

r

The lugsail parameters (r) 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.

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.

eigen_values

eigen values of the estimate cov.

method

method used to calculate matrix cov.

size

value of size used to calculate cov.

Adjustment_Used

whether an adjustment was used to calculate cov.

References

Vats, D., Flegal, J. M., and, Jones, G. L Multivariate output analysis for Markov chain Monte Carlo, Biometrika, 106, 321–-337.

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

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Bivariate Normal with mean (mu1, mu2) and covariance sigma
n <- 1e3
mu <- c(2, 50)
sigma <- matrix(c(1, 0.5, 0.5, 1), nrow = 2)
out <- BVN_Gibbs(n, mu, sigma)

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 documentation built on Sept. 9, 2021, 9:06 a.m.