View source: R/adjust-numeric-calibration.R
adjust_numeric_calibration | R Documentation |
Calibration for regression models involves adjusting the model's predictions to adjust for correlated errors, ensuring that predicted values align closely with actual observed values across the entire range of outputs.
adjust_numeric_calibration(x, method = NULL, ...)
x |
A |
method |
Character. One of |
... |
Optional arguments to pass to the corresponding function in the probably package. These arguments must be named. |
The "linear" method fits a model that predicts the observed versus the
predicted outcome values. This model is used to remove any overt systematic
trends from the data, equivalent to removing the model residuals from new
data. The underlying code fits that model using mgcv::gam()
. If
smooth = FALSE
is passed to the ...
, it uses stats::lm()
.
The isotonic method uses stats::isoreg()
to force the predicted values to
increase with the observed outcome. This creates a step function that will
map new predictions to values that are monotonically increasing with the
outcome. One side effect is that there are fewer, perhaps far fewer, unique
predicted values. The "isotonic boot" method resamples the data and generates
multiple isotonic regressions that are averaged and used to correct the
predictions. This may not be perfectly monotonic, but the number of unique
calibrated predictions increases with the number of bootstrap samples
(controlled by passing the times
argument to ...
).
An updated tailor()
containing the new operation.
This adjustment requires estimation and, as such, different subsets of data should be used to train it and evaluate its predictions.
Note that, when calling fit.tailor()
, if the calibration data have zero or
one row, the method
is changed to "none"
.
library(tibble)
# create example data
set.seed(1)
d_calibration <- tibble(y = rnorm(100), y_pred = y/2 + rnorm(100))
d_test <- tibble(y = rnorm(100), y_pred = y/2 + rnorm(100))
d_calibration
# specify calibration
tlr <-
tailor() |>
adjust_numeric_calibration(method = "linear")
# train tailor on a subset of data.
tlr_fit <- fit(tlr, d_calibration, outcome = y, estimate = y_pred)
# apply to predictions on another subset of data
d_test
predict(tlr_fit, d_test)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.