Erin
Erin

Reputation: 187

How to get p_values of features in survreg?

I working on survival analysis and each time I use a different test set and at the end I would like to have the avg of coefficients, p for each feature and p value of the model. I can get coefficients using srFit$coefficients. But I don't know how to get the p values, although I can see them using 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 

Upvotes: 0

Views: 1793

Answers (2)

Brigitte
Brigitte

Reputation: 829

You can extract the p-values from the table in the summary

s = summary(srFit)
s$table
s$table[,4]

Upvotes: 1

ShruS
ShruS

Reputation: 71

You can examine the statistic names of Summary object using names(summary(srFit)), then extract the statistic you want:
summary(srFit)$statistic_name_here.
If the statistic you want is a table like in your case, you can extract it into a data.frame for eg. df=data.frame(summary(srFit)$statistic_name_here)
df$your_column_name will give you what you want.

Upvotes: 1

Related Questions