Pre-processes subject-level time-to-event data into a long Poisson format on a piecewise-constant time grid, then fits one initialized learner object. For competing risks, a separate model is fit for each event type (cause) using the standard cause-specific Poisson likelihood on the long data.
Usage
fit_learner(
data,
learner,
id = "id",
stratified_k_fold = FALSE,
status = "status",
event_time = NULL,
number_of_nodes = NULL,
nodes = NULL,
variable_transformation = NULL,
...
)Arguments
- data
data.frame. Subject-level input data (one row per subject).- learner
Reference-class learner object (e.g. from
Learner_glmnet(),Learner_hal()orLearner_gam()). Must implement a$private_fit(dt_long)method that fits the learner on long Poisson data for one cause.- id
character(1). Name of the subject identifier column. If not found indata, anidcolumn is created automatically.- stratified_k_fold
logical(1). Reserved argument for future fold strategy. Currently ignored.- status
character(1). Name of the event-status column. Must be coded with0= censoring and1,2,...,Kfor event types (causes). If there is no0instatus, the data are treated as uncensored.- event_time
character(1). Name of the event/censoring time column. Must be present indata.- number_of_nodes
numeric(1)orNULL. If notNULL, constructs a quantile-based node grid withnumber_of_nodes + 1cut points (including endpoints), then adds0if missing.- nodes
numericorNULL. Explicit time-node grid (cut points). If supplied,number_of_nodesis ignored.0is added if missing. Nodes beyondmax(event_time)are dropped.- variable_transformation
list/character/formulaorNULL. Optional transformations applied to the internally created long Poisson data before fitting (viaapply_transformations()).- ...
Additional arguments currently ignored.
Value
An object of class base_learner, i.e. a named list with:
- model
The learner object that was fit (the input
learner), stored for later prediction. This contains the learner specification (e.g., covariates, tuning parameters).- learner_fit
A
listof fitted model objects, one per cause. Its length equalsdata_info$n_crisks. The list is created by splitting the internally pre-processed long data by cause indicatorkand callingmodel$private_fit()on each split.Names typically correspond to the cause labels
"1","2", ...,"K".Each element is learner-dependent: e.g. for
Learner_glmnetit may be a"glmnet"(often wrapped, e.g."fishnet") fit; for other learners it will be whatever$private_fit()returns.Each fitted object is trained on long Poisson data representing the piecewise-constant hazard for that cause across the node intervals.
- data_info
A
listof bookkeeping information needed for prediction and interpretation:- id
Identifier column name used.
- status
Status column name used.
- event_time
Event/censoring time column name used.
- nodes
Numeric vector of node cut points used for the piecewise grid (includes
0and is sorted). These are the interval boundaries used in the long Poisson representation.- maximum_followup
max(data[[event_time]]).- n_crisks
Number of event types (causes) detected. If censoring is present (
0instatus), thenn_crisks = #unique(status) - 1; otherwisen_crisks = #unique(status).- variable_transformation
The transformation specification passed in
variable_transformation(orNULL).
Examples
d <- simulateStenoT1(50, competing_risks = TRUE)
lrn <- Learner_glmnet(covariates = c("age", "value_LDL"),
lambda = 0,
cross_validation = FALSE)
bl <- fit_learner(d,
learner = lrn,
id = "id",
status = "status_cvd",
event_time = "time_cvd",
number_of_nodes = 2)