Carina Salt
2011-Sep-20 14:28 UTC
[R] Using method = "aic" with pspline & survreg (survival library)
Hi everybody. I'm trying to fit a weibull survival model with a spline basis for the predictor, using the survival library. I've noticed that it doesn't seem to be possible to use the aic method to choose the degrees of freedom for the spline basis in a parametric regression (although it's fine with the cox model, or if the degrees of freedom are specified directly by the user), and I was wondering if there is some reason for this? Simple example: library(survival) attach(cancer) # cox model with specified degs of freedom - works fine fit1 <- coxph(Surv(time, status) ~ ph.ecog + pspline(age,3), cancer) # cox model with aic - works fine fit1 <- coxph(Surv(time, status) ~ ph.ecog + pspline(age,method="aic"), cancer) # weibull model with specified degs of freedom - works fine fit1 <- survreg(Surv(time, status) ~ ph.ecog + pspline(age,3), cancer, dist="weibull") # weibull model with aic - gives an error fit1 <- survreg(Surv(time, status) ~ ph.ecog + pspline(age,method="aic"),dist="weibull", cancer) Error in (cfun[[1]])(parmlist[[1]], iter, iterlist[[1]], n.eff, pdf[1], : object 'loglik' not found I also get a similar error about "object 'loglik' not found" if I try to use method="aic" in the specification of a frailty term in a survreg model. Thanks for your help - apologies in advance if I'm missing something very obvious. I'm using R2.13.0 btw, with survival v2.39-9. Regards Carina [[alternative HTML version deleted]]