ElasticNet: Wrapper function for glmnet

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Wrapper function for glmnet

Usage

1
ElasticNet(formula, data, nfolds = 10, ...)

Arguments

formula

Formula where the right hand side specifies the response and the left hand side the predictor matrix

data

A data frame in which formula is evaluated

nfolds

nfolds: number of cross-validation folds in cv.glmnet (default in function is 10)

...

passed on to glmnet

Details

This function first calls cv.glmnet and then evaluates glmnet at the hyper parameter which optimizes the cross-validation criterion.

Value

Object with class ElasticNet

Author(s)

Thomas A. Gerds <[email protected]>

See Also

predictStatusProb

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Generate some data with binary response Y
 # depending on X1 and X2 and X1*X2
set.seed(40)
N <- 40
X1 <- rnorm(N)
X2 <- rbinom(N,1,.4)
X3 <- rnorm(N)
expit <- function(x) exp(x)/(1+exp(x))
lp <- expit(1 + X1 + X2 + X3)
Y <- factor(rbinom(N,1,lp))
dat <- data.frame(Y=Y,X1=X1,X2=X2,X3=X3)

efit <- ElasticNet(Y~X1+X2+X3,data=dat,family="binomial",alpha=0.1)
Brier(efit,verbose=FALSE)

ModelGood documentation built on May 2, 2019, 5 p.m.