[S] plot the fit from the Cox PH model

Dongliang Zhuang (dzhuang@triton.sunlab.ph.ucla.edu)
Mon, 7 Sep 1998 16:17:26 -0700 (PDT)


Dear S+ users:

A question about plotting the fit of the Cox PH model to the data.
I include a categorical variable, say X, in the model. When X has four levels,
I created three dummy variables and used the following commands to plot the fit of the model.

fit_coxph(Surv(t,status)~x1+x2+x3)
newdata_c(0,0,0)
lines(survfit(fit,newdata),lty=3)
for (i in 1:3)
{
newdata[i]_1
newdata[-i]_0
lines(survfit(fit,newdata),lty=3)
}

These work well! However, when I have only two levels for X(X=0,1), I simplify
the command to

fit_coxph(Surv(t,status)~x)
newdata_0
lines(survfit(fit,newdata),lty=3)
newdata_1
lines(survfit(fit,newdata),lty=3)

It didn't work. The error message is:

Error in model.newframe(Terms, newdata, response =..: Invalid frame number, 0
Dumped

What might be wrong? Your help is very aprreciated.

Dongliang Zhuang
Department of Biostatistics
UCLA
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news