## ----setup, include=FALSE-----------------------------------------------------
knitr::opts_chunk$set(
  echo = TRUE, message = FALSE, warning = FALSE,
  collapse = TRUE, comment = "#>"
)
have_cmdstan <- requireNamespace("cmdstanr", quietly = TRUE)

## ----example-fit, eval=have_cmdstan-------------------------------------------
library(gdpar)

set.seed(1)
n <- 80L
df <- data.frame(
  x1 = rnorm(n), x2 = rnorm(n), x3 = rnorm(n)
)
df$y <- 1 + 0.8*df$x1 - 0.6*df$x2 + 0.4*df$x3 +
        rnorm(n, sd = 0.3)

spec <- amm_spec(a = ~ x1 + x2 + x3)

fit <- gdpar(
  formula       = y ~ x1 + x2 + x3,
  family        = gdpar_family("gaussian"),
  amm           = spec,
  data          = df,
  parametrization = "auto",
  iter_warmup   = 300L,
  iter_sampling = 300L,
  chains        = 2L,
  refresh       = 0L,
  verbose       = FALSE,
  seed          = 42L
)

## ----example-resolved, eval=have_cmdstan--------------------------------------
fit$parametrization$cp_a
fit$parametrization$cp_W

## ----example-meta, eval=have_cmdstan------------------------------------------
str(fit$parametrization$meta)

## ----example-decision, eval=have_cmdstan--------------------------------------
fit$parametrization$meta$decision_reason_a
fit$parametrization$meta$t_info_cp_a
fit$parametrization$meta$n_divergent
fit$parametrization$meta$ebfmi_min

