lugsail_gr: Upgraded Univariate and Multivariate Gelman-Rubin Diagnostic

View source: R/lugsail_gr.R

lugsail_grR Documentation

Upgraded Univariate and Multivariate Gelman-Rubin Diagnostic

Description

Computes the upgraded Gelman-Rubin convergence statistics (\hat{R}_L and \hat{R}^p_L), Effective Sample Size (\widehat{\mathrm{ESS}}), and principled termination thresholds (\delta_{\epsilon}) proposed by Vats and Knudson (2021) using replicated lugsail batch means variance estimators.

Usage

lugsail_gr(x, alpha = 0.05, epsilon = 0.1, b = NULL, multivariate = TRUE)

Arguments

x

Input MCMC chain output. Can be a numeric vector (single univariate chain), matrix of dimension (n, p) (single multivariate chain), 3D array of dimension (n, p, m) (multiple multivariate chains), or a list of length m containing matrices or data.frames.

alpha

Numeric, significance level for the confidence region (default 0.05 for 95% confidence).

epsilon

Numeric, relative volume tolerance for target precision (default 0.10).

b

Optional batch size for lugsail batch means. If NULL, defaults to floor(sqrt(n)).

multivariate

Logical, if TRUE (default), computes multivariate Gelman-Rubin diagnostic \hat{R}^p_L and multivariate ESS when p > 1.

Value

An object of class "lugsail_gr" containing:

psrf

Vector of univariate lugsail potential scale reduction factors \hat{R}_L for each parameter.

mpsrf

Multivariate lugsail potential scale reduction factor \hat{R}^p_L.

ess

Vector of univariate effective sample sizes for each parameter.

mess

Multivariate effective sample size \widehat{\mathrm{ESS}}_p.

delta_eps

Principled target threshold \delta_{\epsilon}.

M_alpha_eps_p

Minimum required effective sample size bound M_{\alpha, \epsilon, p}.

converged

Logical, indicating if diagnostic has converged (mpsrf <= delta_eps).

means

Posterior sample mean vector across chains.

sd

Posterior standard deviation vector.

s2

Sample variance (scalar or matrix S).

tau_L

Replicated lugsail variance/covariance matrix estimate \hat{T}_L.

n

Chain length (number of iterations per chain).

m

Number of parallel chains.

p

Number of parameter dimensions.

alpha

Significance level.

epsilon

Relative volume tolerance.

References

Vats, D. and Knudson, C. (2021). Revisiting the Gelman–Rubin Diagnostic. Statistical Science, 36(4), 518–529. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1214/20-STS812")}.

Gelman, A. and Rubin, D. B. (1992). Inference from iterative simulation using multiple sequences. Statistical Science, 7(4), 457–472. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1214/ss/1177011136")}.

Brooks, S. P. and Gelman, A. (1998). General methods for monitoring convergence of iterative simulations. Journal of Computational and Graphical Statistics, 7(4), 434–455. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/10618600.1998.10474787")}.

Examples

# Example 1: Univariate MCMC output (3 chains of 1000 iterations)
set.seed(123)
chain1 <- rnorm(1000, mean = 0, sd = 1)
chain2 <- rnorm(1000, mean = 0.05, sd = 1)
chain3 <- rnorm(1000, mean = -0.05, sd = 1)
res1 <- lugsail_gr(list(chain1, chain2, chain3))
print(res1)

# Example 2: Multivariate MCMC output (2 chains of 500 iterations, 2 parameters)
mat1 <- matrix(rnorm(1000), ncol = 2)
mat2 <- matrix(rnorm(1000), ncol = 2)
res2 <- lugsail_gr(list(mat1, mat2))
summary(res2)

LugsailGR documentation built on Aug. 5, 2026, 9:08 a.m.