Your df object (newdata) has to have ALL the variables in it. Normally you wouldn't need the strata variable, but in this case cov1 is also a covariate. Look at the example I gave earlier.

Terry T.

On 10/15/2012 05:00 AM, r-help-requ...@r-project.org wrote:
Many thanks for your very quick reply!  I tried replacing ?~ strata(cov1) +
cov1:cov2 ? with  ?~ strata(cov1):cov2 ?. As a result, I get an error
message saying that ?object 'cov1' not found?. I guess R refers to the data
frame. Any idea how to fix the error? Complete code follows.

Best regards,
Roland



require(survival)
data(lung)
#
lung$cov1<- as.factor(lung$ph.ecog)
lung$cov2<- as.factor(lung$sex)
levels(lung$cov1)[levels(lung$cov1)==0]<- "zero"
levels(lung$cov1)[levels(lung$cov1)==1]<- "one"
levels(lung$cov1)[levels(lung$cov1)==2]<- "two"
levels(lung$cov1)[levels(lung$cov1)==3]<- "three"
levels(lung$cov2)[levels(lung$cov2)==1]<- "male"
levels(lung$cov2)[levels(lung$cov2)==2]<- "female"
#
df<- data.frame(
   cov2=factor("female", levels = levels(lung$cov2))
)
sCox<- coxph(Surv(time, status) ~ strata(cov1):cov2, data=lung)
sfCox<- survfit(sCox,newdata=df)


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to