Provides tools for fitting piecewise-constant hazard models for survival and competing risks data, including ensemble hazard estimation via the Super Learner framework. The package supports estimation of survival functions and absolute risk predictions from fitted cause-specific hazard models. For the Super Learner framework see van der Laan, Polley and Hubbard (2007)
The package provides an implementation of piecewise-constant hazard models for time-to-event analysis of survival and competing risks data. The piecewise-constant hazard models can be combined in an ensemble, the Poisson Superlearner, via cross-validated risk minimization for flexible hazard estimation. It enables estimation of survival functions and absolute risk predictions.
The package provides:
# install.packages("devtools")
# devtools::install_github("gpitt71/poissonsuperlearner")
library(poissonsuperlearner)
Fit a single PCH model and obtain absolute risk predictions.
library(poissonsuperlearner)
set.seed(42)
# Simulate synthetic survival data
d <- simulateStenoT1(
n = 50,
scenario = "alpha"
)
# Define an unpenalized Poisson hazard learner
l_glm <- Learner_glmnet(
covariates = c("sex", "diabetes_duration"),
cross_validation = FALSE,
lambda = 0
)
# Fit piecewise-constant hazard model
fit_glm <- fit_learner(
data = d,
id = "id",
status = "event",
event_time = "time",
learner = l_glm,
number_of_nodes = 5
)
# Absolute risk prediction at time horizon t = 5
predictRisk(fit_glm, newdata = d[1, ], times = 5)
What happens internally?
number_of_nodes intervals.Combine multiple hazard learners into an ensemble.
library(poissonsuperlearner)
set.seed(42)
d <- simulateStenoT1(
n = 50,
scenario = "alpha"
)
# Base learner 1: unpenalized Poisson regression
l_glm <- Learner_glmnet(
covariates = c("sex", "diabetes_duration"),
cross_validation = FALSE,
lambda = 0
)
# Base learner 2: Lasso-penalized Poisson regression
l_lasso <- Learner_glmnet(
covariates = c("value_Smoking", "value_LDL"),
cross_validation = TRUE,
alpha = 1
)
learners_list <- list(
glm = l_glm,
lasso = l_lasso
)
# Fit the superlearner
sl_fit <- Superlearner(
data = d,
id = "id",
status = "event",
event_time = "time",
learners = learners_list,
number_of_nodes = 5
)
# Absolute risk prediction from the ensemble
predictRisk(sl_fit, newdata = d[1, ], times = 5)
Superlearner workflow
For competing risks, learners may also be a list of cause-specific learner
libraries, one library per cause. Predictions can be requested from the stacked
ensemble (model = "sl"), the discrete super learner (model = "discrete_sl"),
or named/indexed base learners.
Learner_glmnet() - define a Poisson hazard learner.Learner_gam() - define a Poisson GAM hazard learner.Learner_hal() - define a HAL-style Poisson hazard learner.fit_learner() - fit a single piecewise-constant hazard model.Superlearner() - fit an ensemble of hazard learners.predict() - obtain hazards, survival, and absolute risk predictions.predictRisk() - obtain risk matrices compatible with riskRegression.poissonsuperlearner is designed for:
The package focuses on modular learners, transparent cross-validation, and direct control of the piecewise hazard structure.