Scores the joint_model pipeline on the outer splits of an
nested_cv object. As in cv_joint_model, each outer
split's model is fit on its analysis set and scored on its assessment set one row per
subject, and the coxnet model of a start/stop outcome is scored along each subject's
covariate path (covariates), as cv_coxnet does. The inner
resamples are not used to fit anything: the penalty of each outer split's coxnet model
is tuned by the internal cross-validation of joint_model() (unless penalty is
given), and the status and time models choose theirs by cv.glmnet.
Usage
nested_cv_joint_model(
object,
outcome = survival::Surv(time, status) ~ .,
subject_id = NULL,
engine = c("glmnet", "baguette", "stacks"),
calibration = TRUE,
parallel = FALSE,
covariates = c("path", "baseline"),
check_subject_overlap = TRUE,
tune_method = c("none", "race_anova", "race_win_loss"),
checkpoint_dir = NULL,
shard = NULL,
checkpoint_mismatch = c("recompute", "overwrite", "error"),
...
)Arguments
- object
An
rsample::nested_cvobject.- outcome
Survival formula with a
Surv()outcome.- subject_id
Subject identifier column. Required for start/stop outcomes.
- engine
Modeling engine:
"glmnet","baguette", or"stacks"(the"baguette"models plus a stored Cox meta-learner whose outputpredict()adds as extra columns; seejoint_model).- calibration
Logical; whether to calibrate status predictions (default
TRUE).- parallel
Logical; whether to run outer splits in parallel.
- covariates
"path"or"baseline"; seecv_joint_model.- check_subject_overlap
If
TRUE(the default), stop when an outer split, or an inner resample, puts the same subject in both its analysis and its assessment set; see Details.FALSEskips the check.- tune_method
Method for tuning the Cox component penalty on the inner resamples:
"none"(default, uses internal CV ofjoint_model()),"race_anova"(tune_race_anovaracing), or"race_win_loss"(tune_race_win_lossracing, which needs BradleyTerry2). With racing, the penalty found on each outer split's inner resamples replaces anypenaltygiven in....- checkpoint_dir
Optional directory path where per-split checkpoints are stored.
- shard
Optional shard specification (e.g.
c(1, 2)) for distributed computation.- checkpoint_mismatch
Action on mismatch:
"recompute","overwrite", or"error".- ...
Additional arguments passed to
joint_model.
Value
An S3 object of class c("nested_cv_joint_model", "tbl_df"): outer_id,
model, and ibs, one row per outer split and model.
Details
A counting-process (start/stop) outcome needs subject_id, and the outer splits and
every inner resample are checked before anything is fit: if a subject is in both the analysis
and the assessment set of one of them, the function stops, as cv_joint_model does
for supplied resamples. Build object with grouped resampling at both levels, e.g.
nested_cv(data, outside = group_vfold_cv(group = subject_id), inside = group_vfold_cv(group = subject_id)).
Out-of-bag assessment sets of bootstraps pass. check_subject_overlap = FALSE skips the check.
