ref_fit
Usage
ref_fit(spec, data, outcomes, id = NULL, ...)Fits one model per outcome. A failed outcome does not abort the panel:
a non-numeric outcome (factor, character, logical) gets the status
"unsupported_type", one with fewer than eight finite values or no
spread "insufficient_variation", and an engine failure
"nonconverged".
Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
spec |
A ref_spec. |
data |
A data frame of reference observations. |
outcomes |
Tidyselect specification or character vector of outcome columns. The covariate frame is kept wide. |
id |
Optional subject identifier column. It is carried on scores but is never a covariate. |
... |
Passed to the engine fitter. |
Details
Section titled “Details”Covariates are the variables named in the spec’s location, scale,
skew, and tail formulas; other columns are ignored. Each outcome is
fitted on the rows that are complete for that outcome and those
covariates, and a message reports how many rows were dropped.
Outcomes are fitted in parallel when the future.apply package is
installed and a non-sequential future::plan() is active.
An object of class ref_fit. fit$covariates holds the
covariate names.
Examples
Section titled “Examples”ref <- ref_simulate(80, seed = 1)spec <- ref_spec(family = ref_gaussian(), location = ~ age + sex)fit <- ref_fit(spec, data = ref, outcomes = "y")predict(fit, newdata = ref[1:3, ], uncertainty = "conditional")# A tibble: 3 × 15 .row .id .outcome observed median centile z tail_prob tail_surprisal* <int> <int> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>1 1 1 y 8.42 8.90 0.361 -0.355 0.722 0.3252 2 2 y 11.5 9.38 0.940 1.56 0.120 2.123 3 3 y 10.1 10.1 0.496 -0.0106 0.992 0.00845# ℹ 6 more variables: residual <dbl>, log_density <dbl>, support <chr>,# calibrated <lgl>, .in_sample <lgl>, status <chr>