The following works, you need to include x=TRUE in the call to coxph.
Passing the time and status variables as additional arguments is a matter of
personal preference.

f.coxph.zph<-function(x, timeVar, statusVar)
{
        cox.fit <- coxph(Surv(timeVar, statusVar) ~ x, na.action =
na.exclude, method = "breslow", x=TRUE)
        fit.zph<-cox.zph(cox.fit)
        fit.zph$table[,3]
}

time.cox   <- ovarian$futime
status.cox <- ovarian$fustat

apply(ovarian[,-(1:2)],2, f.coxph.zph, timeVar = time.cox, statusVar =
status.cox)


--Matt


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of array chip
Sent: Tuesday, November 09, 2004 16:50 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [S] worked in R, but not in S-Plus


Hi, 

I wrote a function that worked well in R, but not in
S-Plus, can anyone suggest a solution?

> f.coxph.zph<-function(x)
{
        cox.fit <- coxph(Surv(time.cox, status.cox) ~ x,
na.action = na.exclude, method = "breslow")
        fit.zph<-cox.zph(cox.fit,transform='log')
        fit.zph$table[,3]
}

yyy is my data frame that contains survial time,
censor status and predictor variables.

> time.cox<-yyy$time
> status.cox<-yyy$status
> apply(yyy[,-(1:2)],2,f.coxph.zph)

When run in S-Plus, it gave the following error
message:

Problem in model.frame.coxph(fit): Object "x" not
found

If I remove the 2nd and 3rd lines inside the function,
it worked, so definitely something is wrong in passing
the coxph object into the cox.zph().

Thanks






                
__________________________________ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 

--------------------------------------------------------------------
This message was distributed by [EMAIL PROTECTED]  To
...(s-news.. clipped)...

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to