fit-method-sampler_diagnostics: Extract sampler diagnostics after MCMC

fit-method-sampler_diagnosticsR Documentation

Extract sampler diagnostics after MCMC

Description

Extract the values of sampler diagnostics for each iteration and chain of MCMC. To instead get summaries of these diagnostics and associated warning messages use the $diagnostic_summary() method.

Usage

sampler_diagnostics(
  inc_warmup = FALSE,
  format = getOption("cmdstanr_draws_format", "draws_array")
)

Arguments

inc_warmup

(logical) Should warmup draws be included? Defaults to FALSE.

format

(string) The draws format to return. See draws for details.

Value

Depends on format, but the default is a 3-D draws_array object (iteration x chain x variable). The variables for Stan's default MCMC algorithm are "accept_stat__", "stepsize__", "treedepth__", "n_leapfrog__", "divergent__", "energy__".

See Also

CmdStanMCMC

Examples

## Not run: 
fit <- cmdstanr_example("logistic")
sampler_diagnostics <- fit$sampler_diagnostics()
str(sampler_diagnostics)

library(posterior)
as_draws_df(sampler_diagnostics)

# or specify format to get a data frame instead of calling as_draws_df
fit$sampler_diagnostics(format = "df")

## End(Not run)


stan-dev/cmdstanr documentation built on April 21, 2024, 5:38 a.m.