Skip to contents

Creates autocorrelation function (ACF) plots for selected parameters. High autocorrelation indicates slow mixing and low effective sample size.

Usage

plot_acf(fit, pars = NULL, lags = 25, n_pars = 6)

Arguments

fit

A ratiod_fit object.

pars

Character vector of parameter names. If NULL, selects worst-mixing parameters based on ESS.

lags

Maximum number of lags to compute (default: 25).

n_pars

Maximum number of parameters to plot (default: 6).

Value

A ggplot object (if ggplot2 available) or base R plot (invisible).

Details

Ideal ACF plots show rapid decay to zero. Slow decay indicates high autocorrelation, which reduces effective sample size and may indicate poor mixing.

Examples

# \donttest{
sim <- sim_ratiod(n = 100, family = ratiod_poisson_gamma(), seed = 1)
fit <- tratio(y_num | y_denom ~ x1 + (1 | group), data = sim$data,
              family = ratiod_poisson_gamma(),
              control = list(iter = 1000, chains = 2, seed = 1))
plot_acf(fit)

plot_acf(fit, pars = c("beta_num[2]", "sigma_re"))

# }