predictSurvProb function doesn't work
Closed this issue · 3 comments
predictSurvProb() function listed in pammtools (page 28, https://cran.r-project.org/web/packages/pammtools/pammtools.pdf) doesn't work with gam objects created by mgcv::gam (pamm fitted model). So, I can use add_surv_prob only.
From pec library page I found that now it (predictSurvProb) works only with gaussian family implemented for glm, but not gam (https://rdrr.io/cran/pec/src/R/predictSurvProb.R).
Hm, can you show an example: In the vignett on model evaluation it appears to work: https://adibender.github.io/pammtools/articles/model-evaluation.html
library(pammtools)
library(pec)
# fit the model
ped <- tumor[1:250,] %>% as_ped(Surv(days, status) ~ sex + age)
pam <- mgcv::gam(ped_status ~ s(tend) + sex + age, data = ped,
family=poisson(), offset=offset)
# new data
newdata0 <- tumor %>% make_newdata(status= c(1))
ped0 <- newdata0 %>% as_ped(Surv(days, status)~ sex + age)
# predict survival probability
times <- c(1:10)
predictSurvProb(pam, ped0, times)
Hi, in order to use PAMMs with package pec
, you need to fit the model using the pamm
convenience function.
It stores some additional information in order to calculate survival probabilities in a format suitable for pec
.
See here for examples: https://adibender.github.io/pammtools/articles/model-evaluation.html