Monte Carlo standard error (MCSE) of the posterior mean or median, using
the rank-normalized bulk/tail ESS from ess.
kind = "mean": MCSE = SD / sqrt(ess_bulk). kind =
"median": MCSE = sqrt(pi/2) * SD / sqrt(ess_tail) (the closed-form
normal asymptotic-efficiency approximation; 2/pi is the asymptotic
relative efficiency of the sample median vs. the mean under normality).
Usage
mcse(draws, kind = c("mean", "median"))
Arguments
- draws
A matrix of posterior draws (rows = iterations, columns =
parameters) for a single chain, or a list of such matrices (one per
chain, identical dimensions).
- kind
"mean" (default) or "median".
Value
Named numeric vector, one value per parameter (NA when the
underlying ESS or pooled SD is undefined).
Examples
set.seed(42)
draws <- matrix(rnorm(2000), ncol = 2,
dimnames = list(NULL, c("a", "b")))
mcse(draws)
#> a b
#> 0.03173110 0.03347214
mcse(draws, kind = "median")
#> a b
#> 0.04171953 0.04052848