TVP

预后建模绕不开的lasso cox回归

2.4K0

1. 所有参数绝对值之和，即L1范数，对应的回归方法叫做Lasso回归

2. 所有参数的平方和，即L2范数，对应的回归方法叫做Ridge回归，岭回归

lasso回归对应的代价函数如下

The NAD+ metabolism-related prognostic risk score (NPRS) of each sample was calculated using the formula: NPRS = ΣExp (mRNAί) × Coefficient (mRNAί)

In the training cohort, using the Least Absolute Shrinkage And Selection Operator (LASSO) regression with 10-fold cross-validated to screen out NMRGs associated with survival in ALS patients.

Here, the glmnet package was applied to determine the optimal lambda value corresponding to the minimum of the error mean via cross-validation.

https://glmnet.stanford.edu/

https://glmnet.stanford.edu/articles/Coxnet.html

1. 准备输入文件

``````> library(glmnet)

> library(survival)
> data(CoxExample)
> x <- CoxExample\$x
> y <- CoxExample\$y
# 自变量数据，每一行表示一个患者，每一列表示一个自变量
[,1]       [,2]        [,3]       [,4]        [,5]
[1,] -0.8767670 -0.6135224 -0.56757380  0.6621599  1.82218019
[2,] -0.7463894 -1.7519457  0.28545898  1.1392105  0.80178007
[3,]  1.3759148 -0.2641132  0.88727408  0.3841870  0.05751801
[4,]  0.2375820  0.7859162 -0.89670281 -0.8339338 -0.58237643
[5,]  0.1086275  0.4665686 -0.57637261  1.7041314  0.32750715
[6,]  1.2027213 -0.4187073 -0.05735193  0.5948491  0.44328682
# 因变量数据，生存数据的因变量为time加status
time status
[1,] 1.76877757      1
[2,] 0.54528404      1
[3,] 0.04485918      0
[4,] 0.85032298      0
[5,] 0.61488426      1
[6,] 0.29860939      0``````

2. 交叉验证

1. deviance

2. C-index

``````> cvfit <- cv.glmnet(x, y, family = "cox", type.measure = "C", nfolds = 10)
> plot(cvfit)``````

``````> cv.glmnet(x, y, family = "cox", type.measure = "deviance", nfolds = 10)
> plot(cvfit)``````

``````> cvfit\$lambda.min
[1] 0.01749823
> cvfit\$lambda.1se
[1] 0.04868986``````

``````> print(cvfit)

Call:  cv.glmnet(x = x, y = y, type.measure = "deviance", nfolds = 10, family = "cox")

Measure: Partial Likelihood Deviance

Lambda Index Measure      SE Nonzero
min 0.01750    29   13.08 0.06221      15
1se 0.04869    18   13.14 0.05369      10``````

``````> coef(cvfit, s = cvfit\$lambda.1se)
30 x 1 sparse Matrix of class "dgCMatrix"
1
V1   0.38108115
V2  -0.09838545
V3  -0.13898708
V4   0.10107014
V5  -0.11703684
V6  -0.39278773
V7   0.24631270
V8   0.03861551
V9   0.35114295
V10  0.04167588
V11  .
V12  .
V13  .
V14  .
V15  .
V16  .
V17  .
V18  .
V19  .
V20  .
V21  .
V22  .
V23  .
V24  .
V25  .
V26  .
V27  .
V28  .  ``````

·end·

0 条评论

LV.