如何解决如何在crr函数中添加地层变量?
我正在尝试检验Fine和Gray回归,并验证“ crr”软件包和“ survival”软件包是否产生相同的结果。然后将这些结果放入Latex。
生存结果有效,但对于crr结果,我在插入阶层变量时遇到问题。与其将阶层变量视为阶层,不如将其视为因素变量。
这是我的代码:
#Create the model matrix
cov1 <- model.matrix(~ factor(marriage_husbandNP2$factor_age)
+ factor(marriage_husbandNP2$factor_marital)
+ factor(marriage_husbandNP2$factor_rural)
+ relevel((factor(marriage_husbandNP2$factor_crime)),ref="Theft and Burglary")
+ factor(marriage_husbandNP2$factor_religion)
+ factor(marriage_husbandNP2$factor_time)
+ strata(marriage_husbandNP2$factor_child)
+ factor(marriage_husbandNP2$factor_place)
+ factor(marriage_husbandNP2$factor_town),data = marriage_husbandNP2)[,-1]
#create the model
test_newfine <- crr(marriage_husbandNP2$ftime,marriage_husbandNP2$fstatus,cov1=cov1,failcode=1,cencode=0,na.action=na.omit)
#Print the summary of the results
summary.crr(test_newfine)
这是结果的一部分:
factor(marriage_husbandNP2$factor_age)30-39 -0.08958
factor(marriage_husbandNP2$factor_age)40+ -0.03279
factor(marriage_husbandNP2$factor_marital)Married -0.24707
factor(marriage_husbandNP2$factor_rural)Town 0.06140
factor(marriage_husbandNP2$factor_rural)Port cities 0.03485
relevel((factor(marriage_husbandNP2$factor_crime)),ref = "Theft and Burglary")Violent crimes -0.00408
relevel((factor(marriage_husbandNP2$factor_crime)),ref = "Theft and Burglary")Livestock theft 0.69953
relevel((factor(marriage_husbandNP2$factor_crime)),ref = "Theft and Burglary")Arson 0.18090
relevel((factor(marriage_husbandNP2$factor_crime)),ref = "Theft and Burglary")Against society 0.02449
relevel((factor(marriage_husbandNP2$factor_crime)),ref = "Theft and Burglary")UnkNown 0.47567
factor(marriage_husbandNP2$factor_religion)Protestant -0.27935
factor(marriage_husbandNP2$factor_religion)UnkNown -0.85640
factor(marriage_husbandNP2$factor_time)1848-1853 0.47355
strata(marriage_husbandNP2$factor_child)1+ -0.08371
factor(marriage_husbandNP2$factor_place)Munster -0.07983
factor(marriage_husbandNP2$factor_place)Ulster 0.06396
factor(marriage_husbandNP2$factor_place)Connaught 0.03635
factor(marriage_husbandNP2$factor_town)1+ -0.36061
我希望将factor_child作为层次包括在内,而不是作为可见的协变量。 我还从“ crrSC”包中测试了crrs功能。
test_newfine <- crrs(marriage_husbandNP2$ftime,strata=marriage_husbandNP2$factor_child,ctype=1,na.action=na.omit)
尽管确实会产生正确隐藏变量的结果。由于某种原因,所有针对模型整体重要性的测试均无法正常进行。而且,尽管该程序包声明它将产生crr类型的对象,但它不会产生此类型的程序包。
以下是这两个集合的截屏截图(第一个由CRR制作,第二个由CRRS制作):
那么,使用CRR逻辑将阶层变量包含在精细和灰色回归中的最佳方法是什么。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。