简体   繁体   English

coxph() 中的“termlabels”错误 function 生存 package

[英]'termlabels' error in coxph() function of survival package

I am trying to analyse a reoccurring event dataset and I am struggling to fit the model.我正在尝试分析一个重复发生的事件数据集,我正在努力适应 model。

A subset of my data:我的数据的一个子集:

outdat <- structure(list(yr = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3), jday = c(141, 151, 156, 157, 157, 158, 164, 168,  168, 168, 168, 168, 168, 170, 171, 171, 177, 177, 177, 178, 179,   181, 182, 182, 182, 182, 182, 184, 186, 188, 188, 188, 189, 191,     197, 197, 197, 198, 198, 199, 209, 211, 217, 223, 230, 161, 187,    196, 196, 196, 197, 197, 201, 204, 204, 204, 208, 209, 211, 212,     215, 215, 219, 221, 222, 225, 229, 229, 245, 252, 256, 159, 160,    166, 172, 174, 174, 178, 178, 178, 178, 178, 179, 182, 185, 185, 186, 186, 187, 187, 187, 187, 187, 187, 188, 188, 192, 195, 195,     195, 195, 195, 196, 196, 196, 200, 200, 200, 200, 202, 203, 204,     207, 207, 207, 207, 207, 207, 207, 208, 212, 212, 226), out = c(1,   1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), row.names = c(NA,     -123L), class = c("tbl_df", "tbl", "data.frame"))

The data is showing an occurrence of crop disease in a country and I am trying to first the Cox PH model.数据显示一个国家发生了作物病害,我首先尝试的是 Cox PH model。 The survival package manual recommends defining the term cluster() in the formula. survival package 手册建议在公式中定义术语cluster()

cm <- coxph(Surv(time =jday, event = out ) ~ cluster(yr), data = outdat)
Error in reformulate(temp[1 - tcl]) : 
'termlabels' must be a character vector of length at least one  

If I do not define covariate as a grouping variable the model is fitted.如果我没有将协变量定义为分组变量,则安装 model。

cm <- coxph(Surv(time =jday, event = out ) ~ yr, data = outdat)

Note that I have tried changing the class of outdat$yr to character/factor.请注意,我已尝试将outdat$yr的 class 更改为字符/因子。

A cluster() term adjusts the standard errors of the hazards, but since it's the only term on the right hand side of the formula, you have no covariates to adjust. cluster()项调整危害的标准误差,但由于它是公式右侧的唯一项,因此您无需调整协变量。 You need at least one covariate.您至少需要一个协变量。 And I wouldn't include the cluster term unless you had a specific reason to.除非您有特定的理由,否则我不会包含集群术语。

See here for more info请参阅此处了解更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM