[R] survfit & number of variables != number of variable names

Terry Therneau therneau at mayo.edu
Mon Nov 19 18:01:38 CET 2012


I can't reproduce the problem.

Tell us what version of R and what version of the survival package.
Create a reproducable example.  I don't know if some variables are numeric and some are 
factors, how/where the "surv" object was defined, etc.

Terry Therneau



On 11/17/2012 05:00 AM, r-help-request at r-project.org 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?
>
> Best, and thank you,
>
> ge




More information about the R-help mailing list