Title: | Monte Carlo Standard Errors for MCMC |
---|---|
Description: | Provides tools for computing Monte Carlo standard errors (MCSE) in Markov chain Monte Carlo (MCMC) settings. MCSE computation for expectation and quantile estimators is supported as well as multivariate estimations. The package also provides functions for computing effective sample size and for plotting Monte Carlo estimates versus sample size. |
Authors: | James M. Flegal <[email protected]>, John Hughes, Dootika Vats <[email protected]>, Ning Dai, Kushagra Gupta, and Uttiya Maji |
Maintainer: | Dootika Vats <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.5-0 |
Built: | 2024-11-03 06:47:57 UTC |
Source: | CRAN |
Provides tools for computing Monte Carlo standard errors (MCSE) in Markov chain Monte Carlo (MCMC) settings. MCSE computation for expectation and quantile estimators is supported. The package also provides functions for computing effective sample size and for plotting Monte Carlo estimates versus sample size.
Package: | mcmcse |
Type: | Package |
Version: | 1.5-0 |
Date: | 2021-08-29 |
License: | GPL (>= 2) |
James M. Flegal <[email protected]>,
John Hughes,
Dootika Vats, <[email protected]>,
Ning Dai,
Kushagra Gupta, and
Uttiya Maji
Maintainer: Dootika Vats <[email protected]>
Dai, N and Jones, G.L. (2017) Multivariate initial sequence estimators in Markov chain Monte Carlo, Journal of Multivariate Analysis, 159, 184-199.
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, pages 363–372. 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.
Doss, C. R., Flegal, J. M., Jones, G. L., and Neath, R. C. (2014). Markov chain Monte Carlo estimation of quantiles. Electronic Journal of Statistics, 8, 2448-2478.
Gong, L., and Flegal, J. M. A practical sequential stopping rule for high-dimensional Markov chain Monte Carlo. Journal of Computational and Graphical Statistics, 25, 684–-700.
Heberle, J., and Sattarhoff, C. (2017). A fast algorithm for the computation of HAC covariance matrix estimators. Econometrics, 5, 9.
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.
Liu, Y., Vats, D., and Flegal, J. M. (2021) Batch size selection for variance estimators in MCMC, Methodology and Computing in Applied Probability, to appear.
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.
n <- 1e3 mu = c(2, 50) sigma = matrix(c(1, 0.5, 0.5, 1), nrow = 2) out = BVN_Gibbs(n, mu, sigma) multiESS(out) ess(out) mcse.mat(out) mcse.bm <- mcse.multi(x = out) mcse.tuk <- mcse.multi(x = out, method = "tukey")
n <- 1e3 mu = c(2, 50) sigma = matrix(c(1, 0.5, 0.5, 1), nrow = 2) out = BVN_Gibbs(n, mu, sigma) multiESS(out) ess(out) mcse.mat(out) mcse.bm <- mcse.multi(x = out) mcse.tuk <- mcse.multi(x = out, method = "tukey")
Function returns the optimal batch size (or truncation point) for a given chain and method.
batchSize(x, method = c("bm", "obm", "bartlett", "tukey", "sub"), g = NULL, fast = TRUE)
batchSize(x, method = c("bm", "obm", "bartlett", "tukey", "sub"), g = NULL, fast = TRUE)
x |
A matrix or data frame of Markov chain output. Number of rows is the Monte Carlo sample size. |
method |
Any of “ |
g |
A function that represents features of interest. |
fast |
Boolean variable for fast estimation using a reasonable subset of the Markov chain. |
batchSize
fits a stationary autoregressive process to the marginals of x
, selecting the order of
the process as the one with the maximum AIC among the models with coefficients greater than a threshold.
A value of the optimal batch size (truncation point or bandwidth) is returned.
Liu, Y., Vats, D., and Flegal, J. M. (2021) Batch size selection for variance estimators in MCMC, Methodology and Computing in Applied Probability, to appear.
mcse.multi
and mcse
, which calls on batchSize
.
## 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) batchSize(out) batchSize(out, method = "obm") batchSize(out, method = "bartlett")
## 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) batchSize(out) batchSize(out, method = "obm") batchSize(out, method = "bartlett")
Function returns Gibbs samples from a bivariate normal target density.
BVN_Gibbs(n, mu, sigma)
BVN_Gibbs(n, mu, sigma)
n |
Sample size of the Markov chain. |
mu |
A 2 dimensional vector. Mean of the target normal distribution. |
sigma |
2 x 2 symmetric positive definite matrix. The covariance matrix of the target normal distribution. |
An n x 2 matrix of the Gibbs samples.
n <- 1e3 mu <- c(2, 50) sigma <- matrix(c(1, 0.5, 0.5, 1), nrow = 2) out <- BVN_Gibbs(n, mu, sigma)
n <- 1e3 mu <- c(2, 50) sigma <- matrix(c(1, 0.5, 0.5, 1), nrow = 2) out <- BVN_Gibbs(n, mu, sigma)
Constructs confidence regions (ellipses) from the Markov chain output for the features of interest Function uses the ellipse package.
confRegion(mcse.obj, which = c(1,2), level = .95)
confRegion(mcse.obj, which = c(1,2), level = .95)
mcse.obj |
The list returned by the mcse.multi or mcse.initseq command, or an mcmcse class object. |
which |
Integer vector of length 2 indicating the component for which to make the confidence ellipse. Chooses the first two by default. |
level |
confidence level for the ellipse. |
Returns a matrix of x and y coordinates for the ellipse. Use plot function on the matrix to plot the ellipse.
## 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) mcerror <- mcse.multi(out, blather = TRUE) ## Plotting the ellipse plot(confRegion(mcerror), type = 'l')
## 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) mcerror <- mcse.multi(out, blather = TRUE) ## Plotting the ellipse plot(confRegion(mcerror), type = 'l')
Estimate the effective sample size (ESS) of a Markov chain as described in Gong and Flegal (2015).
ess(x, g = NULL, ...)
ess(x, g = NULL, ...)
x |
a matrix or data frame of Markov chain output. Number of rows is the Monte Carlo sample size. |
g |
a function that represents features of interest. |
... |
arguments passed on to the |
ESS is the size of an iid sample with the same variance as the current sample for estimating the expectation of g. ESS is given by
where is the sample variance and
is an estimate of the variance in the Markov chain central limit theorem. The denominator by default
is a batch means estimator, but the default can be changed with the 'method' argument.
The function returns the estimated effective sample size for each component of g
.
Gong, L. and Flegal, J. M. (2015) A practical sequential stopping rule for high-dimensional Markov chain Monte Carlo, Journal of Computational and Graphical Statistics, 25, 684—700.
minESS
, which calculates the minimum effective samples required for the problem.
multiESS
, which calculates multivariate effective sample size using a Markov chain
and a function g
.
Create a plot that shows how Monte Carlo estimates change with increasing sample size.
estvssamp(x, g = mean, main = "Estimates vs Sample Size", add = FALSE, ...)
estvssamp(x, g = mean, main = "Estimates vs Sample Size", add = FALSE, ...)
x |
a sample vector. |
g |
a function such that |
main |
an overall title for the plot. The default is “ |
add |
logical. If |
... |
additional arguments to the plotting function. |
NULL
## 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) estvssamp(out[,1], main = expression(E(x[1])))
## 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) estvssamp(out[,1], main = expression(E(x[1])))
Check if the class of the object is mcmcse
is.mcmcse(x)
is.mcmcse(x)
x |
The object that is checked to belong to the class mcmcse |
Boolean variable indicating if the input belongs to the class mcmcse
## 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) is.mcmcse(mcse.multi(out))
## 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) is.mcmcse(mcse.multi(out))
Compute Monte Carlo standard errors for expectations.
mcse(x, size = NULL, g = NULL, r = 3, method = "bm", warn = FALSE)
mcse(x, size = NULL, g = NULL, r = 3, method = "bm", warn = FALSE)
x |
a vector of values from a Markov chain of length n. |
size |
represents the batch size in “ |
g |
a function such that |
r |
The lugsail parameters ( |
method |
any of “ |
warn |
a logical value indicating whether the function should issue a warning if the sample size is too small (less than 1,000). |
mcse
returns a list with three elements:
est |
an estimate of |
se |
the Monte Carlo standard error. |
nsim |
The number of samples in the input Markov chain. |
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, pp. 363-372. 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.
Doss, C. R., Flegal, J. M., Jones, G. L., and Neath, R. C. (2014). Markov chain Monte Carlo estimation of quantiles. Electronic Journal of Statistics, 8, 2448-2478. 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–154.
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.
## 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) x = out[,1] 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")
## 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) x = out[,1] 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")
Function returns the estimate of the covariance matrix in the Markov Chain central limit theorem using initial sequence method. This method is designed to give an asymptotically conservative estimate of the Monte Carlo standard error.
mcse.initseq(x, g = NULL, adjust = FALSE, blather = FALSE)
mcse.initseq(x, g = NULL, adjust = FALSE, blather = FALSE)
x |
A matrix or data frame of Markov chain output. Number of rows is the Monte Carlo sample size. |
g |
A function that represents features of interest. |
adjust |
Logical; if |
blather |
if |
A list is returned with the following components,
cov |
a covariance matrix estimate using intial sequence method. |
cov.adj |
a covariance matrix estimate using adjusted initial sequence method if the
input |
eigen_values |
eigen values of the estimate cov. |
method |
method used to calculate matrix cov. |
est |
estimate of g(x). |
nsim |
number of rows of the input x. Only if |
Adjustment_Used |
logical of whether an adjustment was made to the initial sequence estimator.
Only if |
Dai, N and Jones, G.L. (2017) Multivariate initial sequence estimators in Markov chain Monte Carlo, Journal of Multivariate Analysis, 159, 184-199.
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.
mcse.multi
, which estimates the covariance matrix in the
Markov Chain CLT using batch means or spectral variance methods.
## 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) out.mcse <- mcse.initseq(x = out) out.mcse.adj <- mcse.initseq(x = out, adjust = TRUE) # 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)) out.g.mcse <- mcse.initseq(x = out, g = g)
## 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) out.mcse <- mcse.initseq(x = out) out.mcse.adj <- mcse.initseq(x = out, adjust = TRUE) # 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)) out.g.mcse <- mcse.initseq(x = out, g = g)
mcse
to each column of the MCMC samples.Apply mcse
to each column of the MCMC samples.
mcse.mat(x, size = NULL, g = NULL, method = "bm", r = 3)
mcse.mat(x, size = NULL, g = NULL, method = "bm", r = 3)
x |
a matrix of values from a Markov chain of size n x p. |
size |
represents the batch size in “ |
g |
a function such that |
method |
any of “ |
r |
The lugsail parameters ( |
mcse.mat
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 th row of the matrix contains the result
of applying
mcse
to the th column of
x
.
mcse
, which acts on a vector.
mcse.multi
, for a multivariate estimate of the Monte Carlo standard error.
mcse.q
and mcse.q.mat
, which compute standard errors for quantiles.
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)
mcse.multi(x, method = "bm", r = 3, size = NULL, g = NULL, adjust = TRUE, blather = FALSE)
x |
A matrix or data frame of Markov chain output. Number of rows is the Monte Carlo sample size. |
method |
Any of “ |
r |
The lugsail parameters ( |
size |
Represents the batch size in “ |
g |
A function that represents features of interest. |
adjust |
Defaults to |
blather |
If |
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. |
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.
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.
## 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)
## 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)
Compute Monte Carlo standard errors for quantiles.
mcse.q(x, q, size = NULL, g = NULL, method = c("bm", "obm", "sub"), warn = FALSE)
mcse.q(x, q, size = NULL, g = NULL, method = c("bm", "obm", "sub"), warn = FALSE)
x |
a vector of values from a Markov chain. |
q |
the quantile of interest. |
size |
the batch size. The default value is “ |
g |
a function such that the |
method |
the method used to compute the standard error. This is one of “ |
warn |
a logical value indicating whether the function should issue a warning if the sample size is too small (less than 1,000). |
mcse.q
returns a list with three elements:
est |
an estimate of the |
se |
the Monte Carlo standard error. |
nsim |
The number of samples in the input Markov chain. |
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.
Doss, C. R., Flegal, J. M., Jones, G. L., and Neath, R. C. (2014). Markov chain Monte Carlo estimation of quantiles. Electronic Journal of Statistics, 8, 2448-2478. 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–154 .
mcse.q.mat
, which applies mcse.q
to each column of a matrix or data frame.
mcse
and mcse.mat
, which compute standard errors for expectations.
## 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) x <- out[,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")
## 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) x <- out[,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")
mcse.q
to each column of a matrix or data frame of MCMC samples.Apply mcse.q
to each column of a matrix or data frame of MCMC samples.
mcse.q.mat(x, q, size = NULL, g = NULL, method = c("bm", "obm", "sub"))
mcse.q.mat(x, q, size = NULL, g = NULL, method = c("bm", "obm", "sub"))
x |
a matrix or data frame with each row being a draw from the multivariate distribution of interest. |
q |
the quantile of interest. |
size |
the batch size. The default value is “ |
g |
a function such that the |
method |
the method used to compute the standard error. This is one of “ |
mcse.q.mat
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 th row of the matrix contains
the result of applying
mcse.q
to the th column of
x
.
mcse.q
, which acts on a vector.
mcse
and mcse.mat
, which compute standard errors for expectations.
The function calculates the minimum effective sample size required for a specified relative tolerance level. This function can also calculate the relative precision in estimation for a given estimated effective sample size.
minESS(p, alpha = .05, eps = .05, ess = NULL)
minESS(p, alpha = .05, eps = .05, ess = NULL)
p |
dimension of the estimation problem. |
alpha |
Confidence level. |
eps |
Tolerance level. The eps value is ignored is |
ess |
Estimated effective sample size. Usually the output value from |
The minimum effective samples required when estimating a vector of length p
, with confidence and tolerance of
is
The above equality can also be used to get from an already obtained estimate of
mESS.
By default function returns the minimum effective sample required for a given eps
tolerance. If ess
is specified, then the value returned is the eps
corresponding to that ess
.
Gong, L., and Flegal, J. M. A practical sequential stopping rule for high-dimensional Markov chain Monte Carlo. Journal of Computational and Graphical Statistics, 25, 684–-700.
Vats, D., Flegal, J. M., and, Jones, G. L Multivariate output analysis for Markov chain Monte Carlo, Biometrika, 106, 321–-337.
multiESS
, which calculates multivariate effective sample size using a
Markov chain and a function g.
ess
which calculates univariate effective sample size using a Markov chain and a
function g.
minESS(p = 5)
minESS(p = 5)
Calculate the effective sample size of the Markov chain, using the multivariate dependence structure of the process.
multiESS(x, covmat = NULL, g = NULL, ...)
multiESS(x, covmat = NULL, g = NULL, ...)
x |
a matrix or data frame of Markov chain output. Number of rows is the Monte Carlo sample size. |
covmat |
optional matrix estimate obtained using |
g |
a function that represents features of interest. |
... |
arguments for |
Effective sample size is the size of an iid sample with the same variance as the current sample. ESS is given by
where is the
sample covariance matrix for
g
and is an estimate of the Monte Carlo standard
error for
g
.
The function returns the estimated effective sample size.
Vats, D., Flegal, J. M., and, Jones, G. L Multivariate output analysis for Markov chain Monte Carlo, Biometrika, 106, 321–-337.
minESS
, which calculates the minimum effective samples required for the
problem.
ess
which calculates univariate effective sample size using a Markov chain and a
function g.
## 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) multiESS(out)
## 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) multiESS(out)