如何获得幸存的p_values功能?

时间:2015-10-15 03:01:05

标签: r

我正在进行生存分析,每次使用不同的测试集时,最后我想得到平均系数,p为模型的每个特征和p值。我可以使用srFit $系数得到系数。但我不知道如何获得p值,虽然我可以使用summary(srFit)看到它们。

summary(srFit)

Call:
survreg(formula = Surv(time) ~ f1 + f2 + f3 + f4 + f5 + f6 + f7 + f8 + f9 + f10, data = train, dist = dist_pred[i_dist])
                            Value Std. Error       z        p
(Intercept)              1.59e+03   632.0632  2.5092 1.21e-02
f1                      -2.07e+00     1.2283 -1.6881 9.14e-02
f2                       1.03e+00     1.8070  0.5677 5.70e-01
f3                      -7.61e-02     1.3764 -0.0553 9.56e-01
f4                      -3.24e+00     1.4836 -2.1843 2.89e-02
f5                       4.37e-01     0.0961  4.5474 5.43e-06
f6                      -1.36e+00     0.7555 -1.8011 7.17e-02
f7                      -6.26e-03     0.0081 -0.7719 4.40e-01
f8                       3.92e-03     0.0186  0.2111 8.33e-01
f9                      -4.82e-01     0.4291 -1.1235 2.61e-01
f10                     -7.79e-01     0.3139 -2.4809 1.31e-02
Log(scale)               2.73e+00     0.0314 86.9447 0.00e+00

Scale= 15.4 

Student-t distribution: parmameters= 4
Loglik(model)= -4542.1   Loglik(intercept only)= -4570.1
    Chisq= 56 on 10 degrees of freedom, p= 2.1e-08 
Number of Newton-Raphson Iterations: 5 
n= 1008 

1 个答案:

答案 0 :(得分:0)

如果查看survival:::summary.survreg,您可以看到如何计算p值,即

table <- matrix(rep(coef, 4), ncol = 4) dimnames(table) <- list(cname, c("Value", "Std. Error", "z", "p")) stds <- sqrt(diag(object$var)) table[, 2] <- stds table[, 3] <- table[, 1]/stds table[, 4] <- 2 * pnorm(-abs(table[, 3]))

是实际打印的表。换句话说,可以使用

survreg对象获取p值

with(srFit, 2*pnorm(-abs(coefficients / sqrt(diag(var)))) )