tagteam / prodlim

Product limit estimation for survival analysis
7 stars 9 forks source link

`EventHistory.frame()` does not accept a survival response constructed outside of the formula #2

Closed hfrick closed 2 years ago

hfrick commented 2 years ago

I'd like to be able to make the response object outside of the model formula but EventHistory.frame() is looking for a specification inside the formula. Would it be possible to change that so it checks the class of the response? I'm happy to send a PR with that change.

https://github.com/tagteam/prodlim/blob/9ef7609f72d8364dc8ff8e990046a4d56895b54a/R/EventHistory.frame.R#L165-L167

library(prodlim)
library(survival)

names(lung)[2:3]
#> [1] "time"   "status"
lung2 <- lung[, -c(2,3)]
lung2$surv <- Surv(lung$time, lung$status)

prodlim::prodlim(surv ~ ., data = lung2)
#> Error in EventHistory.frame(formula = formula, data = data, unspecialsDesign = FALSE, : formula is NOT a proper survival formula,
#> which must have a `Surv' or `Hist' object as response.

Created on 2022-10-12 by the reprex package (v2.0.1)

tagteam commented 2 years ago

thanks for reporting this. I just pushed a new version where the error is removed. please let me know if it works for you as well. however, ~. still fails because there are too many continuous variables in lung.

hfrick commented 2 years ago

Works for me, thank you!