Dfmacox和SmoothHr:运行代码中的错误

Dfmacox和SmoothHr:运行代码中的错误,r,smoothing,cubic-spline,hazard,R,Smoothing,Cubic Spline,Hazard,我试图从我的数据集运行一个统计分析代码(连续预测的风险比曲线的非参数估计)。这是我的数据集: 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,

我试图从我的数据集运行一个统计分析代码(连续预测的风险比曲线的非参数估计)。这是我的数据集:

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"))
db2编辑
我已经在你的问题中添加了数据。由于您从
Excel
导入了数据,因此需要将其更改为
data.frame
,因为
smoothHR
可能无法与默认值(包括
tbl\u df
tbl
一起工作

db2<-data.frame(db2)
db2$a <- db2$LnNTproBNP
db2$b <- db2$OS60m
df1 <- dfmacox(time = "OS60m_m", status = "b", nl.predictors = c('a'), 
               smoother = 'ns', method = 'AIC', data=db2)
df1
编辑 我已经在你的问题中添加了数据。由于您从
Excel
导入了数据,因此需要将其更改为
data.frame
,因为
smoothHR
可能无法与默认值(包括
tbl\u df
tbl
一起工作

db2<-data.frame(db2)
db2$a <- db2$LnNTproBNP
db2$b <- db2$OS60m
df1 <- dfmacox(time = "OS60m_m", status = "b", nl.predictors = c('a'), 
               smoother = 'ns', method = 'AIC', data=db2)
df1

我们能得到一些样本数据吗?我们能得到一些样本数据吗?这是一个数据问题。这就是为什么提供可复制的示例很重要。我将首先编辑您的问题以添加带有
dput
的数据,然后编辑我的答案。这是一个数据问题。这就是为什么提供可复制的示例很重要。我将首先编辑您的问题以添加带有
dput
的数据,然后编辑我的答案。
$df
[1] 2

$AIC
[1] 720.0194

$AICc
[1] 722.272

$BIC
[1] 725.2096

$myfit
Call:
coxph(formula = covar, data = data, x = TRUE)

                  coef exp(coef) se(coef)      z     p
ns(a, df = 2)1  0.8969    2.4519   1.0972  0.817 0.414
ns(a, df = 2)2 -0.4574    0.6329   0.3684 -1.242 0.214

Likelihood ratio test=2.25  on 2 df, p=0.3248
n= 99, number of events= 99 

$method
[1] "AIC"

$nl.predictors
[1] "a"