On Nov 16, 2012, at 6:05 PM, Georges Dupret wrote:
This works ok:
cox = coxph(surv ~ bucket*(today + accor + both) + activity, data =
data)
fit = survfit(cox, newdata=data[1:100,])
but using strata leads to problems:
cox.s = coxph(surv ~ bucket*(today + accor + both) +
strata(activity),
data = data)
fit.s = survfit(cox.s, newdata=data[1:100,])
Error in model.frame.default(data = data[1:100, ], formula = ~bucket
+ :
number of variables != number of variable names
Note that the following give rise to the same error:
fit.s = survfit(cox.s, newdata=data)
Error in model.frame.default(data = data, formula = ~bucket + today
+ :
number of variables != number of variable names
but if I use data implicitly, all is working fine:
fit.s = survfit(cox.s)
Any idea on how I could solve this?
I noticed that you were using what might be called an "externally
created Surv object". I have a memory that Terry Therneau has
criticized that practice. I cannot remember if it was in exactly this
situation but I might ask if setting up the model as:
cox = coxph(Surv(stime, event) ~ bucket*(today + accor + both) +
activity, data = data)
... might give the survival machinery a better handle on where
everything might be found.
--
David.
David Winsemius, MD
Alameda, CA, USA
______________________________________________
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.