6
$\begingroup$

I would like to use model selection through shrinkage (Lasso) using glmnet. So far I did the following:

> library(glmnet)
> library(survival)
> d <- myTestData
> x <- model.matrix( ~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8, d)
> y <- Surv(d$time, d$status)
> fit <- glmnet(x, y, family="cox", alpha=1)
> plot(fit, label=T)
> cv.fit <- cv.glmnet(x, y, family="cox", alpha=1)
> plot(cv.fit)

glmnet-plot

cv.glmnet-plot

Question #1: How would you interpret the model selection by Lasso in this case?

Then I retrieved the variables with nonzero coefficients at lambda.min and compared themwith the coefficients of an coxph model using the same variables.

> coef(cv.fit, s = "lambda.min")
9 x 1 sparse Matrix of class "dgCMatrix"
                       1
(Intercept)  .          
x1           0.575711489
x2           0.292638801
x3           .          
x4           0.004826889
x5           .          
x6           .          
x7          -0.045450370
x8          -0.032665220
> m1 <- coxph(Surv(time, status) ~ x1 + x2 + x4 + x7 + x8, data=d) # selected by LASSO
> coef(m1)
         x1          x2          x4          x7          x8 
 0.72538227  0.30256729  0.01394998 -0.09512841 -0.03507133

The Lasso coefficients are smaller than the coxph coefficients, which is for my understanding to avoid overfitting.

Question #2: Is the way of variable selection by Lasso correct this way?

Question #3: Would it be possible to get an coxph or cph object from the Lasso objects?

Question #4: How can I get the HR, its CI andP-value for presentation from this?

Then I did also a backward selection:

> fastbw(fit, type="individual", rule="aic")

 Deleted Chi-Sq d.f. P      Residual d.f. P      AIC  
 x3      0.02   1    0.8897 0.02     1    0.8897 -1.98
 x5      0.03   1    0.8701 0.05     2    0.9773 -3.95
 x6      0.18   1    0.6701 0.23     3    0.9730 -5.77
 x4      0.72   1    0.3974 0.94     4    0.9182 -7.06
 x7      1.49   1    0.2221 2.43     5    0.7863 -7.57

Approximate Estimates after Deleting Factors

       Coef    S.E. Wald Z         P
x1  0.70903 0.32241  2.199 2.787e-02
x2  0.32185 0.06857  4.694 2.680e-06
x8 -0.03761 0.01446 -2.601 9.308e-03

Factors in Final Model

[1] x1 x2 x8

The resulting coefficients are similar to the coefficients obtained from coxph.

Question #5: Is the slight difference due to rounding error or is there more?

I really looking forward to your replies ... I find it hard to get into this subject together with R and need some help. ;-)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.