Skip to contents

Learner_gam is a Reference Class implementing the learner interface used by Superlearner() and fit_learner().

Arguments

covariates

character. Right-hand-side terms, including mgcv smooths (e.g. "s(age)") and/or linear terms (e.g. "value_LDL").

cross_validation

logical. Included for compatibility with the learner interface; smoothing selection is controlled by mgcv and arguments in ....

Details

User-facing API: users should only initialize the learner and pass it to Superlearner() / fit_learner(). The remaining methods documented below are part of the internal learner interface and are not meant to be called directly by users.

Wrapper role: this class wraps mgcv::bam in a piecewise-constant hazard workflow. The package-specific contribution is to provide a convenient interface for the long-format Poisson likelihood with offsets for time at risk, and optional node terms encoding the baseline hazard, while forwarding standard mgcv::bam arguments supplied via ....

Model

Let \(0=t_0 < t_1 < \cdots < t_m\) denote time knots and define interval indicators \(I_k(t)=1\{t\in(t_k,t_{k+1}]\}\). The piecewise-constant hazard model with an additive predictor is $$ \lambda(t \mid x) = \sum_{k=0}^{m} I_k(t)\,\exp\{\eta(x) + \gamma_k\}. $$ The additive predictor \(\eta(x)\) is constructed from covariates (smooth terms such as s(age) and/or linear terms) and estimated by mgcv.

Fields

covariates (character)

Terms used to build the additive predictor (may include s() terms).

cross_validation (logical)

Workflow flag; see Details.

intercept (logical)

Whether to include an intercept.

formula (character)

Formula string passed to mgcv::bam.

learner (function)

Backend fitter (mgcv::bam).

fit_arguments (list)

Additional arguments forwarded to mgcv::bam.

Methods (internal learner interface)

initialize(...)

Construct and configure the learner. This is the only method users should call.

private_fit(data, ...)

Internal. Fits a Poisson GAM with offset log(tij) on long-format data.

private_fit_all_causes(data, ...)

Internal. Fits cause-specific Poisson GAMs for all requested causes using a shared long-format data setup.

private_predictor(model, newdata, ...)

Internal. Predicts hazards on the response scale.

Examples

lrn <- Learner_gam(covariates = c("s(age)", "value_LDL"))