最近在研究生存分析,发现R语言中做没有因子(即自变量x)的生存分析时,类似这种语句
surv.all<-survfit(Surv(month,status)~1),右边的括号要写~1才能运行,这是为什么呢,其中的~1又是什么意思?
解答
先看看R语言官方文档survfit()方法中对传入参数formula的解释
A formula object or a
coxphobject. If a formula object is supplied it must have aSurvobject as the response on the left of the~operator and, if desired, terms separated by operators on the right. One of the
意思是说如果只有一条生存曲线,~右侧应该是1,如果按照某一个分层变量做多个生存曲线,则~右侧就是分层变量,比如按性别分层做两条曲线就可以是~sex。类似一般的回归模型,~1就是只有Y-intercept,没有自变量X-intercept。
版权属于:。。。源
本文链接:https://cloud.tencent.com/developer/article/2169608
转载时须注明出处及本声明。我的博客即将同步至腾讯云开发者社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=2py75w7904qok


