Skip to contents

Convert retained posterior samples to coda objects for chain diagnostics and plotting.

Usage

as_mcmc(object, ...)

Arguments

object

An stLMM, stLMM_chains, stLMM_recovery, or stLMM_recovery_chains object.

...

Additional arguments passed to methods. Supported arguments include include_w, logical, burn, a nonnegative integer, and thin, a positive integer.

Details

Single-chain fits are returned as coda::mcmc. Multi-chain fits are returned as coda::mcmc.list. By default, saved or recovered latent process samples w are omitted because they can be high-dimensional and are often not needed for covariance-parameter diagnostics.

For ordinary fitted objects, burn and thin select retained MCMC rows by row number. For recovered objects, include_w = TRUE aligns parameter samples to recover_iter before appending saved or recovered latent process draws. In that case, burn is interpreted on the original posterior iteration scale and thin is applied to the recovered draws that remain after burn-in. Multi-chain recovery objects apply the same rule within each chain and return a coda::mcmc.list.

Value

A coda::mcmc or coda::mcmc.list object containing active posterior sample blocks such as fixed effects, grouped random effects, residual variance parameters, process variances, and process correlation parameters.

Examples

set.seed(1)
dat <- data.frame(y = rnorm(8), x = seq(-1, 1, length.out = 8))
fit <- stLMM(y ~ x, data = dat, n_samples = 8, warmup = FALSE, verbose = FALSE)
m <- as_mcmc(fit, burn = 2)
coda::effectiveSize(m)
#> (Intercept)           x      tau_sq 
#>           6           6           6