Warnings and summaries of sampler diagnostics. To instead get
the underlying values of the sampler diagnostics for each iteration and
chain use the $sampler_diagnostics()
method.
Currently parameter-specific diagnostics like R-hat and effective sample
size are not handled by this method. Those diagnostics are provided via
the $summary() method (using
posterior::summarise_draws()).
Usage
diagnostic_summary(
diagnostics = c("divergences", "treedepth", "ebfmi"),
quiet = FALSE
)Arguments
- diagnostics
(character vector) One or more diagnostics to check. The currently supported diagnostics are
"divergences","treedepth", and"ebfmi". The default is to check all of them.- quiet
(logical) Should warning messages about the diagnostics be suppressed? The default is
FALSE, in which case warning messages are printed in addition to returning the values of the diagnostics.
Value
A list with as many named elements as diagnostics selected. The
possible elements and their values are:
"num_divergent": A vector of the number of divergences per chain."num_max_treedepth": A vector of the number of timesmax_treedepthwas hit per chain."ebfmi": A vector of E-BFMI values per chain,NAfor a chain whose energy never changes (a model with no parameters).
See also
CmdStanMCMC and the
$sampler_diagnostics() method
Examples
# \dontrun{
fit <- cmdstanr_example("schools")
#> Warning: 121 of 4000 (3.0%) transitions ended with a divergence.
#> See https://mc-stan.org/misc/warnings for details.
#> Warning: 1 of 4 chains had an E-BFMI less than 0.3.
#> See https://mc-stan.org/misc/warnings for details.
fit$diagnostic_summary()
#> Warning: 121 of 4000 (3.0%) transitions ended with a divergence.
#> See https://mc-stan.org/misc/warnings for details.
#> Warning: 1 of 4 chains had an E-BFMI less than 0.3.
#> See https://mc-stan.org/misc/warnings for details.
#> $num_divergent
#> [1] 23 29 31 38
#>
#> $num_max_treedepth
#> [1] 0 0 0 0
#>
#> $ebfmi
#> [1] 0.3927448 0.2994857 0.3067239 0.3595112
#>
fit$diagnostic_summary(quiet = TRUE)
#> $num_divergent
#> [1] 23 29 31 38
#>
#> $num_max_treedepth
#> [1] 0 0 0 0
#>
#> $ebfmi
#> [1] 0.3927448 0.2994857 0.3067239 0.3595112
#>
# }