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

## ----api_group, eval=FALSE----------------------------------------------------
# fit <- gdpar(
#   formula = y ~ x1 + x2,
#   family  = gdpar_family("gaussian"),
#   amm     = amm_spec(a = ~ x1 + x2),
#   data    = df,
#   group   = ~ school    # promotes theta_ref to per-school anchor
# )

## ----coef_example, eval=FALSE-------------------------------------------------
# cf <- coef(fit)
# cf$theta_ref          # one row per (g, k)
# cf$mu_theta_ref       # population-level mu
# cf$sigma_theta_ref    # population-level sigma
# as.data.frame(cf)     # long-tidy: component, g, k, identifier, x_name, mean, q05, q50, q95

## ----predict_example, eval=FALSE----------------------------------------------
# new_df <- df[1:10, ]
# new_df$school <- factor(c(rep("school_A", 8), rep("new_school_X", 2)),
#                         levels = c(levels(df$school), "new_school_X"))
# # predict() emits a single warning naming "new_school_X" and uses the
# # prior predictive marginal for those two rows:
# pred <- predict(fit, newdata = new_df, summary = "draws")

