Checks MCMC convergence diagnostics — R-hat and effective sample size — against user-specified thresholds, and reports any parameters that fail either check.
Arguments
- fitted_model
A fitted model object of class
EpiStrainDynamics.fit, as returned byfit_model().- rhat_threshold
R-hat threshold for convergence (default 1.1). Values above this threshold indicate chains have not mixed well.
- eff_sample_threshold
Effective sample size threshold (default 100). Values below this threshold indicate the posterior samples for a parameter are too autocorrelated to reliably estimate its distribution.
Value
An object of class list, returned invisibly, containing:
- convergence
Logical;
TRUEif no parameter fails either threshold- rhat_issues
Character vector of parameter names with R-hat above
rhat_threshold- eff_sample_issues
Character vector of parameter names with effective sample size below
eff_sample_threshold- max_rhat
The largest R-hat value across all parameters
- min_neff
The smallest effective sample size across all parameters
- summary
The full
rstan::summary()table the above are derived from
Examples
if (FALSE) { # interactive()
mod <- construct_model(
pathogen_structure = single(
case_timeseries = sarscov2$cases,
time = sarscov2$date
),
method = random_walk()
)
fit <- fit_model(mod)
diagnose_model(fit)
}
