Performs K-fold cross-validation either from a fitted model or from
formula + data. For ordinal (cumulative/ordinal) families, you can
choose the re-fit engine used inside CV: TMB (qbrmO) or a robust
fallback using MASS::polr that avoids TMB compilation in each fold.
Your original fitted model is unchanged.
kfold_cv(
object,
data = NULL,
family = gaussian(),
K = 10,
folds = NULL,
seed = NULL,
stratify = TRUE,
parallel = FALSE,
workers = NULL,
keep_fits = FALSE,
engine = c("auto", "tmb", "polr"),
verbose = TRUE,
...
)An object of class qbrms_kfold with ELPD, pointwise elpd, SE, etc.
Either a fitted qbrms/qbrmO object or a formula.
Required only if object is a formula. Ignored if object is a fit.
Optional family override (used if object is a formula; fits use their own).
Number of folds (default 10).
Optional integer vector of length nrow(data) giving fold IDs.
Optional seed for stratified folds.
Logical; stratify on response if factor/ordered (default TRUE).
Logical; use future.apply if available (default FALSE).
Optional workers when parallel and no plan is set.
Logical; keep per-fold fits (default FALSE).
Ordinal CV engine: "auto" (default), "tmb", or "polr".
Only used for ordinal families during CV refits. "auto" uses
getOption("qbrms.kfold.ordinal_engine", "polr").
Logical; brief progress (default TRUE).
Passed to qbrms() when refitting folds (non-ordinal or engine="tmb").