Skip to contents

Checks MCMC diagnostics (Rhat, ESS, divergences) and prints actionable warnings with suggestions for fixing issues.

Usage

check_diagnostics(fit, quiet = FALSE)

Arguments

fit

A ratiod_fit object

quiet

Logical; if TRUE, suppress output and just return status.

Value

Invisibly returns a list with diagnostic status:

ok

Logical; TRUE if all diagnostics pass

n_divergent

Number of divergent transitions

n_bad_rhat

Number of parameters with Rhat > 1.01

n_low_ess

Number of parameters with ESS < 400

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))
check_diagnostics(fit)
#> Diagnostic Check
#> ================
#> 
#> RHAT:  4  parameter(s) have Rhat > 1.01.
#>   This indicates chains have not converged.
#>   Suggestions:
#>     - Run more iterations
#>     - Run more chains
#>     - Check for multimodality with plot(fit)
#> 
#> ESS:  6  parameter(s) have ESS < 400.
#>   This indicates high autocorrelation in samples.
#>   Suggestions:
#>     - Run more iterations
#>     - Increase thinning interval
#>     - Consider reparameterization
#> 
# }