Learn R Programming

gelnet (version 1.2.1)

gelnet.L1bin: A GELnet model with a requested number of non-zero weights

Description

Binary search to find an L1 penalty parameter value that yields the desired number of non-zero weights in a GELnet model.

Usage

gelnet.L1bin(f.gelnet, nF, l1s, max.iter = 10)

Arguments

f.gelnet
a function that accepts one parameter: L1 penalty value, and returns a typical GELnets model (list with w and b as its entries)
nF
the desired number of non-zero features
l1s
the right side of the search interval: search will start in [0, l1s]
max.iter
the maximum number of iterations of the binary search

Value

  • The model with the desired number of non-zero weights and the corresponding value of the L1-norm parameter. Returned as a list with three elements: [object Object],[object Object],[object Object]

Details

The method performs simple binary search starting in [0, l1s] and iteratively training a model using the provided f.gelnet. At each iteration, the method checks if the number of non-zero weights in the model is higher or lower than the requested nF and adjusts the value of the L1 penalty term accordingly. For linear regression problems, it is recommended to initialize l1s to the output of L1.ceiling.

See Also

L1.ceiling

Examples

Run this code
X <- matrix( rnorm(100*20), 100, 20 )
y <- rnorm(100)
l1s <- L1.ceiling( X, y )
f <- function( l1 ) {gelnet.lin( X, y, l1, l2 = 1 )}
m <- gelnet.L1bin( f, nF = 50, l1s = l1s )
print( m$l1 )

Run the code above in your browser using DataLab