Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- glmnet(x, y, alpha=0, family="binomial")
- rm(list=ls())
- # Load libraries
- if(!require("glmnet")) { install.packages("glmnet"); require("glmnet") }
- x=matrix(rnorm(100*20),100,20)
- y=rnorm(100)
- g2=sample(1:2,100,replace=TRUE)
- g4=sample(1:4,100,replace=TRUE)
- # Ridge
- fit11 = glmnet(x,y, alpha=0)
- # Elastic Net
- fit12 = glmnet(x,y, alpha=0.5)
- # Lasso
- fit13 = glmnet(x,y, alpha=1)
- par(mfrow=c(3,1))
- plot(fit11,xvar="lambda", xlim=c(-7,5))
- plot(fit12,xvar="lambda", xlim=c(-7,5))
- plot(fit13,xvar="lambda", xlim=c(-7,5))
Add Comment
Please, Sign In to add comment