r - 为什么R不重新调平?
问题描述
请在My data "w"
下面找到。
我有协变量 w$WHO,它具有三个级别:w$WHO==1, w$WHO==2 and w$WHO==3
我想重新调平,所以 w$WHO==1 被设置为参考。
我试过了
w$WHO <- factor(w$WHO)
w$WHO <- relevel(w$WHO, ref=1)
和
w$WHO <- relevel(w$WHO, ref="1")
我的脚本是
library(rms)
d <- datadist(w)
options(datadist="d")
model <- cph(Surv(rfs,recurrence)~age + WHO,data=w)
summary(model)
如您所见,调整后的模型选择w$WHO==2
作为参考。
Effects Response : Surv(rfs, recurrence)
Factor Low High Diff. Effect S.E. Lower 0.95 Upper 0.95
age 48.545 68.907 20.362 0.28228 0.093283 0.099454 0.46512
Hazard Ratio 48.545 68.907 20.362 1.32620 NA 1.104600 1.59220
WHO - 1:2 2.000 1.000 NA -0.56706 0.156850 -0.874490 -0.25963
Hazard Ratio 2.000 1.000 NA 0.56719 NA 0.417080 0.77134
WHO - 3:2 2.000 3.000 NA 0.69360 0.152910 0.393910 0.99330
Hazard Ratio 2.000 3.000 NA 2.00090 NA 1.482800 2.70010
这是我的数据
My data
w <- structure(list(age = c(54.36164384, 74.91232877, 64.98356164,
60.56712329, 57.61369863, 45.85205479, 78.47123288, 59.95616438,
57.4739726, 25.12876712, 56.61917808, 61.10136986, 58.74246575,
62.56438356, 55.81917808, 30.83013699, 63.11232877, 56.29863014,
47.96986301, 40.53424658, 49.9890411, 47.75616438, 40.83835616,
42.02191781, 49.85205479, 55.05479452, 59.33424658, 71.89589041,
60.30410959, 50.24383562, 41.3260274, 33.4, 73.27945205, 67.45753425
), WHO = c(3L, 1L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 3L,
2L, 3L, 2L, 1L, 2L, 1L, 1L, 2L, 3L, 1L, 2L, 1L, 1L, 3L, 1L, 1L,
1L, 1L, 1L, 1L, 1L), recurrence = c(1L, 1L, 1L, 1L, 0L, 1L, 0L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), rfs = c(19.1, 15.33333333,
49.16666667, 15.6, 57.16666667, 47.63333333, 54, 16.93333333,
6.7, 102.1, 24.33666667, 127.7666667, 100.6333333, 25.96666667,
1.233333333, 13.1, 72.16666667, 62, 97.23333333, 199.1, 24.73333333,
60.46666667, 10.43333333, 31.76666667, 28.96666667, 56.43333333,
9.533333333, 114.9333333, 114.8666667, 85.06666667, 107.6, 121.2,
69.56666667, 70.03333333)), .Names = c("age", "WHO", "recurrence",
"rfs"), class = "data.frame", row.names = 271:304)
谢谢,最好的。
解决方案
解决方案是
d$limits$WHO[2] <- 1
model <- cph(Surv(rfs,recurrence)~age + WHO,data=w)
summary(model)
推荐阅读
- ssis - 优先约束在SSIS中评估为真(或假)是什么意思
- python - 分解python中的列表理解
- mysql - mySQL 删除唯一键约束
- firebase - 如何以相反的顺序从 Firebase 数据库添加数据?
- d3.js - 将 y 轴水平线添加到 D3 散点图
- swift - 带有扩展部分的 Swift UITableView,在选定的新部分上强制关闭已打开的部分
- list - Swiftui 移除滑动删除功能
- android - 依次运行两个倒数计时器
- r - Creating a one variable when multiple answers are chosen -- in R
- list - 如何使用 SharedPreferences 从 Flutter 中的列表中保存多个布尔值