library(glmnet) library(survival) dat <- readRDS('../../../COXPH/data/PRAD.rds') y <- Surv(round(dat$meta$pfs_time,2), dat$meta$pfs_status ==1) y <- data.matrix(y) pfg <- readRDS('../../fig.2/D_ref_A_fiig.2_D/x.rds') x <- dat$data[,pfg$RRA] x <- as.matrix(x) # x <- model.matrix(~.,clinical) lasso <- glmnet(x = x, y = y, family ='cox', alpha =1)
LASSO图确定λ与变量个数的关系
1 2 3 4
lasso pdf(file ='lasso_p1.pdf');plot(lasso, xvar="lambda", label=T);dev.off() lasso.coef <- predict(lasso, s =0.039720, type ='coefficients') lasso.coef