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.
mcse.multi(x, method = "bm", r = 3, size = NULL, g = NULL,
adjust = TRUE, blather = FALSE)
A matrix or data frame of Markov chain output. Number of rows is the Monte Carlo sample size.
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.
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.
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)).
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.
Defaults to TRUE
. logical for whether the matrix should automatically be adjusted if unstable.
If TRUE
, returns under-the-hood workings of the package.
A list is returned with the following components,
a covariance matrix estimate.
estimate of g(x).
number of rows of the input x.
eigen values of the estimate cov.
method used to calculate matrix cov.
value of size used to calculate cov.
whether an adjustment was used to calculate cov.
Vats, D., Flegal, J. M., and, Jones, G. L Multivariate output analysis for Markov chain Monte Carlo, Biometrika, 106, 321<U+2013>-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<U+2013>-1909.
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.
# NOT RUN {
## 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)
# }
Run the code above in your browser using DataLab