Compute AICc and BIC for glmnet logistic models.

rerr(v1, v2)

ridge_logistic(X, Y, lambda, beta0, beta, maxiter = 1000, tol = 1e-10)

BIC_glmnetB(Z, Y, glmnet.model, alpha, modelSet, reducer = "median")

AICc_glmnetB(Z, Y, glmnet.model, alpha, modelSet, reducer = "median")

Arguments

v1

A numeric vector.

v2

A numeric vector.

X

A numeric matrix

Y

A numeric 0/1 vector.

lambda

A numeric value.

beta0

A numeric value Initial intercept value.

beta

A numeric vector. Initial coefficient values.

maxiter

A numeric value. Maximum number of iterations.

tol

A numeric value. Tolerance value.

Z

A numeric matrix

glmnet.model

A fitted glmnet model.

alpha

A numeric value.

modelSet

Modelset to consider.

reducer

A character value. Reducer function. Either 'median' or 'mean'.

Value

A list relevant to model selection.

Details

Calculate AICc and BIC for glmnet logistic models from the glmnetB function of the package rLogistic https://github.com/echi/rLogistic and adapted to deal with non finite exponential values in AICc and BIC computations

References

Robust Parametric Classification and Variable Selection by a Minimum Distance Criterion, Chi and Scott, Journal of Computational and Graphical Statistics, 23(1), 2014, p111--128, doi:10.1080/10618600.2012.737296 .

See also

Author

Frederic Bertrand, frederic.bertrand@utt.fr

Examples

set.seed(314)
xran=matrix(rnorm(150),30,5)
ybin=sample(0:1,30,replace=TRUE)
glmnet.fit <- glmnet.fit <- glmnet::glmnet(xran,ybin,family="binomial",standardize=FALSE)
set.seed(314)
rerr(1:10,10:1)
#> [1] 4.5

set.seed(314)
ridge_logistic(xran,ybin,lambda=.5,beta0=rnorm(5),beta=rnorm(5,1))
#> $b0
#> [1] -1.0960525  0.9196443 -0.6407416 -0.5114932  0.3194314
#> 
#> $beta
#>            [,1]
#> [1,] 0.23919027
#> [2,] 0.67464504
#> [3,] 0.23926363
#> [4,] 0.01414993
#> [5,] 1.43243321
#> 
#> $iters
#> [1] 33
#> 

set.seed(314)
if(is.factor(ybin)){ynum=unclass(ybin)-1} else {ynum=ybin}
subSample <- 1:min(ncol(xran),100)
BIC_glmnetB(xran,ynum,glmnet.fit,alpha=1,subSample, reducer='median')
#> $BIC
#> [1] 1.257217 1.116147 1.116147 1.116147 1.116147
#> 
#> $minBIC
#> [1] 1.116147
#> 
#> $dof
#> [1] 0 1 1 1 1
#> 
#> $activeSets
#> $activeSets[[1]]
#> named integer(0)
#> 
#> $activeSets[[2]]
#> V5 
#>  5 
#> 
#> $activeSets[[3]]
#> V5 
#>  5 
#> 
#> $activeSets[[4]]
#> V5 
#>  5 
#> 
#> $activeSets[[5]]
#> V5 
#>  5 
#> 
#> 
#> $bestSet
#> V5 
#>  5 
#> 
#> $model
#> $model$a0
#>         s4 
#> -0.1697716 
#> 
#> $model$beta
#>          [,1]
#> [1,] 1.138298
#> 
#> $model$df
#> [1] 1
#> 
#> $model$lambda
#> [1] 0
#> 
#> 

set.seed(314)
if(is.factor(ybin)){ynum=unclass(ybin)-1} else {ynum=ybin}
subSample <- 1:min(ncol(xran),100)
AICc_glmnetB(xran,ynum,glmnet.fit,alpha=1,subSample, reducer='median')
#> $AICc
#> [1] 1.257217 1.071819 1.071819 1.071819 1.071819
#> 
#> $minAICc
#> [1] 1.071819
#> 
#> $dof
#> [1] 0 1 1 1 1
#> 
#> $activeSets
#> $activeSets[[1]]
#> named integer(0)
#> 
#> $activeSets[[2]]
#> V5 
#>  5 
#> 
#> $activeSets[[3]]
#> V5 
#>  5 
#> 
#> $activeSets[[4]]
#> V5 
#>  5 
#> 
#> $activeSets[[5]]
#> V5 
#>  5 
#> 
#> 
#> $bestSet
#> V5 
#>  5 
#> 
#> $model
#> $model$a0
#>         s4 
#> -0.1697716 
#> 
#> $model$beta
#>          [,1]
#> [1,] 1.138298
#> 
#> $model$df
#> [1] 1
#> 
#> $model$lambda
#> [1] 0
#> 
#>