我正在尝试从我的数据集中运行代码进行统计分析(连续预测变量的风险比曲线的非参数估计)。这是我的数据集:
db2 <-structure(list(IBM = c(2, 3, 2, 5, 0, 0, 3, 0, 0, 4,
0, 2, 0, 5, 2, 0, 2, 5, 4, 3, 3, 0, 2, 0, 0, 5, 0, 2, 0, 4, 3,
4, 4, 2, 2, 3, 0, 2, 4, 0, 2, 0, 3, 5, 3, 0, 3, 1, 0, 2, 3, 0,
2, 3, 2, 0, 3, 2, 2, 3, 3, 3, 2, 1, 2, 2, 4, 2, 2, 2, 4, 0, 0,
0, 2, 2, 3, 2, 2, 3, 3, 0, 2, 0, 0, 5, 3, 2, 2, 2, 0, 3, 3, 2,
2, 2, 2, 0, 2),
OS60m = 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),
OS60m_m = c(32, 22, 58, 44, 34, 26, 12, 1, 4, 7, 23,
9, 2, 16, 3, 50, 17, 36, 19, 44, 1, 0, 4, 35, 45, 25, 57, 8,
11, 1, 13, 30, 38, 59, 21, 32, 35, 21, 10, 57, 0, 39, 0, 30,
33, 17, 55, 51, 27, 13, 15, 8, 35, 6, 2, 27, 55, 37, 12, 18,
13, 47, 20, 43, 29, 19, 25, 34, 20, 13, 17, 16, 37, 45, 57, 25,
20, 45, 29, 28, 22, 33, 2, 45, 16, 38, 35, 11, 58, 40, 6, 4,
47, 27, 45, 39, 34, 2, 56),
LnNTproBNP = c(3.58, 3.78, 3.99,
4.22, 4.32, 4.52, 4.54, 4.61, 4.69, 4.75, 4.8, 4.88, 4.91, 4.93,
4.94, 4.96, 4.98, 4.98, 5.06, 5.09, 5.19, 5.23, 5.23, 5.26, 5.29,
5.29, 5.3, 5.32, 5.33, 5.41, 5.42, 5.42, 5.45, 5.47, 5.48, 5.49,
5.5, 5.52, 5.52, 5.52, 5.53, 5.55, 5.59, 5.6, 5.61, 5.62, 5.64,
5.65, 5.65, 5.67, 5.7, 5.71, 5.71, 5.71, 5.73, 5.74, 5.75, 5.78,
5.79, 5.79, 5.8, 5.81, 5.81, 5.82, 5.83, 5.84, 5.84, 5.84, 5.85,
5.86, 5.86, 5.86, 5.91, 5.91, 5.92, 5.94, 5.94, 5.95, 5.96, 5.96,
5.97, 5.98, 5.99, 6, 6.02, 6.02, 6.03, 6.06, 6.06, 6.08, 6.08,
6.09, 6.1, 6.11, 6.11, 6.12, 6.13, 6.15, 6.15)),
row.names = c(NA,-99L), class = c("tbl_df", "tbl", "data.frame"))
这是我试图运行的代码:
a <- db2$LnNTproBNP
b <- db2$OS60m
df1 <- dfmacox(data = db2, time = db2$OS60m_m, status = 'b', nl.predictors = c('a'),
smoother = 'ns', method = 'AIC')
df1$df
hr1 <- smoothHR(time = 'db2$OS60m_m', status = 'b',
formula = ~ns (a, df = df1$df), data = db2)
我收到以下错误:
1) 参数“时间”中定义的变量不在数据集“数据”中
当我运行代码的第一行时;
2) 时间必须是数字或整数类
当我运行第二行和第三行时。