如何在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制作):

Produced by CRR

Produced by CRRS

那么,使用CRR逻辑将阶层变量包含在精细和灰色回归中的最佳方法是什么。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...