Skip to content

Commit

Permalink
fix: aalen and cox.aalen support when using method="direct" in adjust…
Browse files Browse the repository at this point in the history
…edsurv()
  • Loading branch information
RobinDenz1 committed Sep 23, 2024
1 parent 4331d0c commit 27a185e
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions R/method_direct.r
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,12 @@ surv_g_comp <- function(outcome_model, data, variable, times,
newdata=data_temp,
times=times,
...)
# use function from pec package for fast & easy survival prediction
# NOTE: while aalen & cox.aalen are not working in predictRisk, keep them
# here
# use function from pec package for fast & easy survival prediction
} else if (inherits(outcome_model, c("pecCforest", "pecRpart",
"selectCox", "aalen", "cox.aalen"))) {
"selectCox"))) {
requireNamespace("pec")

# get model.matrix if needed
if (inherits(outcome_model, c("aalen"))) {
mod_vars <- all.vars(outcome_model$call$formula)
mod_form <- paste0(" ~ ", paste0(mod_vars, collapse=" + "))
mod_data <- as.data.frame(stats::model.matrix(
stats::as.formula(mod_form), data=data_temp))
} else {
mod_data <- data_temp
}
mod_data <- data_temp

# predict survival
surv_lev <- pec::predictSurvProb(outcome_model,
Expand All @@ -115,7 +105,8 @@ surv_g_comp <- function(outcome_model, data, variable, times,
"ranger", "rfsrc", "riskRegression",
"ARR", "penfitS3", "gbm",
"flexsurvreg", "singleEventCB",
"wglm", "hal9001"))) {
"wglm", "hal9001", "aalen",
"cox.aalen"))) {
requireNamespace("riskRegression")

surv_lev <- quiet(riskRegression::predictRisk(object=outcome_model,
Expand Down

0 comments on commit 27a185e

Please sign in to comment.