[R] a question in coxph

Lei Liu liulei at virginia.edu
Sun Nov 8 21:25:19 CET 2009


Hi there,

I tried to fit a penalized spline for a continuous risk factor in 
recurrent events data. I found that I can include both pspline and 
frailty terms in coxph. So I use code like

   fit1 <- coxph(Surv(start, end, event)~pspline(age, df=0) + male + 
white +frailty(id), data.all)

It yields results for both age spline and frailty variance. Next I 
tried to draw the plot for age effect. I used termplot function

   termplot(fit1, terms=c(1), se=TRUE)

However, it gives me some error message:

Error in dimnames(pred) <- list(dimnames(x)[[1]], termname) :
   length of 'dimnames' [2] not equal to array extent

I don't know why. However, if I delete the frailty option, and use only

   fit2 <- coxph(Surv(start, end, event)~pspline(age, df=0) + male + 
white, data.all)

I can generate the plot by

termplot(fit2, terms=c(1), se=TRUE)

So it seems to me that adding the frailty() option makes the 
"termplot" function fail to work? Do you know how to draw the plot 
for my function fit1? Thanks a lot!

Lei


At 09:53 AM 7/20/2009, you wrote:
>  I would be willing to chair the session.
>         Terry Therneau
>




More information about the R-help mailing list