From 3dc07cb9d8424eb5e56f3008e8a94462ac092e78 Mon Sep 17 00:00:00 2001 From: Hannah Frick Date: Mon, 18 Dec 2023 19:16:41 +0000 Subject: [PATCH] default to penalty specified during fit this mimicks what `survival_prob_coxnet()` does --- R/proportional_hazards-glmnet.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/proportional_hazards-glmnet.R b/R/proportional_hazards-glmnet.R index 11989b4..42b9dd2 100644 --- a/R/proportional_hazards-glmnet.R +++ b/R/proportional_hazards-glmnet.R @@ -411,6 +411,10 @@ multi_predict_coxnet_linear_pred <- function(object, new_data, opts, penalty) { #' fit(Surv(time, status) ~ ., data = lung) #' survival_time_coxnet(cox_mod, new_data = lung[1:3, ], penalty = 0.1) survival_time_coxnet <- function(object, new_data, penalty = NULL, multi = FALSE, ...) { + if (is.null(penalty)) { + penalty <- object$spec$args$penalty + } + n_obs <- nrow(new_data) n_penalty <- length(penalty) if (n_penalty > 1 & !multi) {