“Wrong number of args for this type of survival data” when coding a survival object in R

牧云@^-^@ 提交于 2019-12-12 22:20:20

问题


I'm experiencing the above error message when trying to run a survival analysis with Weibull distribution, in R.

My data is a bit tricky in that it contains both left and right censored observations.

I followed instructions found on https://stat.ethz.ch/R-manual/R-devel/library/survival/html/Surv.html:

"Interval censored data can be represented in two ways. For the first use type = "interval" and the codes shown above. In that usage the value of the time2 argument is ignored unless event=3. The second approach is to think of each observation as a time interval with (-infinity, t) for left censored, (t, infinity) for right censored, (t,t) for exact and (t1, t2) for an interval. This is the approach used for type = interval2. Infinite values can be represented either by actual infinity (Inf) or NA. The second form has proven to be the more useful one."

I decided to follow the second form, and coded my data with the following headings:

t1, t2 (start and end times), status (0,1,2), factor1, factor2

To run my model I write in R:

    model1 <- survreg(Surv(t1, t2, status, type='interval2')~factor(factor1) + factor(factor2), dist='weibull', data=data)

However, it is consistently giving me the error message:

    Error in Surv(paduration, status, type = "interval") : Wrong number of args for this type of survival data

I have no idea what I am doing wrong, as there are only 5 possible arguments for surv() objects, and the origin argument is irrelevant to my case. when I tried to use less argument, it still gives me the same error message. I've tried to do "type=interval" instead but still get the same error message.

Please help.

来源:https://stackoverflow.com/questions/28467885/wrong-number-of-args-for-this-type-of-survival-data-when-coding-a-survival-obj

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!