survfit & number of variables != number of variable names
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Terry, I attached a small data set to this email. This is what I get (I restricted the formula to avoid NA's):
surv = with(small, Surv(time=absence, event=(censored==FALSE))) (cox.s = coxph(surv ~ bucket*(today) + strata(activity), data = small))
Call:
coxph(formula = surv ~ bucket * (today) + strata(activity), data = small)
coef exp(coef) se(coef) z p
bucket575 0.4526 1.572 0.740 0.612 0.54
todayTRUE -0.0886 0.915 0.676 -0.131 0.90
bucket575:todayTRUE -0.1670 0.846 0.794 -0.210 0.83
Likelihood ratio test=2.32 on 3 df, p=0.509 n= 100, number of
events= 100
fit = survfit(cox.s, newdata=small[1:50,])
Error in model.frame.default(data = small[1:50, ], formula = ~bucket + : number of variables != number of variable names
also:
R.version
_ platform x86_64-redhat-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major 2 minor 15.1 year 2012 month 06 day 22 svn rev 59600 language R version.string R version 2.15.1 (2012-06-22) nickname Roasted Marshmallows package ?survival? is version 2.36-14 and finally, variable absence is numeric, bucket & activity are factors and all other variables are logical. I tested the same formula without 'strata' and I had no problem. Best and thank you, ge
On 11/19/2012 09:01 AM, Terry Therneau wrote:
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
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with undefined - http://www.enigmail.net/ iQEcBAEBAgAGBQJQqoIKAAoJEDf4/Woixvcht1gH/iHxE1liaML5j/8ruEfXX85P vNeQaZHDVZnrYDCbBPxgO/SlpIUmDatUOO9vhG1vBjnalMnftHJqBJCLz8lFswNy z2CepUe2HoX/CcKI5QVlPfXvYzWHBHXbKwYmq9dI+WpNZg0qbyeP3n4ac4ZBsNN+ uzT7gjacA60/zfVOf7D+Rdno+W15Xd8ySrHZU3naPutGN7mGWdgVUlP2wwudad19 2HlTVun40OYLV9TWLJsstYgtead4PamDXvCYrQWZeC29CQesOJ0KzUpojAYWtOpb jZkeh3F+7xKIa4DuBsGQBnIvf8b+vguvSPpVfkrjLCD/6jtVDyyslp6vEISyikw= =+M15 -----END PGP SIGNATURE----- -------------- next part -------------- A non-text attachment was scrubbed... Name: small.csv.gz.sig Type: application/pgp-signature Size: 287 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121119/4a026e7e/attachment.bin>