Hello,
I am trying to write a function 'myfun' to run analyses pertaining
to models of the following form:
Surv(time) ~ sex + m1 +p1 +m1*p1
Surv(time) ~ sex + m2 +p2 +m2*p2
Surv(time) ~ sex + m3 +p3 +m3*p3
.... and so on
My code is something like this and it seems to work:
gp100.data <- sas.get(library="..", member="gp100")
attach(gp100.data)
attr(gp100.data,"na.action")=na.omit
myfun1 <- function(nr){
cno = round(nr,3)
formula1 = as.formula(paste("Surv(t1)~sex+m",cno,
"+p",cno,"+m",cno,"*p",cno,
sep=""))
#zph1 <- cox.zph(fit1)
fit1 = coxph(formula1, data=gp100.data)
fit1
}
> myfun1(1)
Call:
coxph(formula = formula1, data = gp100.data)
coef exp(coef) se(coef) z p
sex 0.1652 1.180 0.0661 2.497 0.013
m1 -0.0381 0.963 0.1851 -0.206 0.840
p1 -0.1470 0.863 0.1753 -0.839 0.400
m1:p1 0.3836 1.468 0.2667 1.438 0.150
Unfortunately when the line with cox.zph is uncommented out the program
does not work. The error message is:
Problem in model.frame.coxph(fit): Object "formula1" not found
Would you like to suggest how to fix this program?
Thank you
Andrzej Galecki
.......................................................................
Andrzej Galecki 300 NIB Rm. 937
E-mail: agalecki@umich.edu Institute of Gerontology
tel. (734) 936 2138 University of Michigan
FAX. (734) 936 2116 Ann Arbor, MI 48109-2007
......................................................................
-----------------------------------------------------------------------
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
|