Learn R Programming

hierNet (version 1.9)

hierNet: A Lasso for interactions

Description

One of the main functions in the hierNet package. Builds a regression model with hierarchically constrained pairwise interactions. Required inputs are an x matrix of features (the columns are the features) and a y vector of values. Reasonably fast for moderate sized problems (100-200 variables). We are currently working on an alternate algorithm for large scale problems.

Usage

hierNet(x, y, lam, delta=1e-8, strong=FALSE, diagonal=TRUE, aa=NULL, zz=NULL,
        center=TRUE, stand.main=TRUE, stand.int=FALSE, 
        rho=nrow(x), niter=100, sym.eps=1e-3,
        step=1, maxiter=2000, backtrack=0.2, tol=1e-5, trace=0)

Arguments

x

A matrix of predictors, where the rows are the samples and the columns are the predictors

y

A vector of observations, where length(y) equals nrow(x)

lam

Regularization parameter (>0). L1 penalty param is lam * (1-delta).

delta

Elastic Net parameter. Squared L2 penalty param is lam * delta. Not a tuning parameter: Think of as fixed and small. Default 1e-8.

strong

Flag specifying strong hierarchy (TRUE) or weak hierarchy (FALSE). Default FALSE.

diagonal

Flag specifying whether to include "pure" quadratic terms, th_jjX_j^2, in the model. Default TRUE.

aa

An *optional* argument, a list with results from a previous call

zz

An *optional* argument, a matrix whose columns are products of features, computed by the function compute.interactions.c

center

Should features be centered? Default TRUE; FALSE should rarely be used. This option is available for special uses only

stand.main

Should main effects be standardized? Default TRUE.

stand.int

Should interactions be standardized? Default FALSE.

rho

ADMM parameter: tuning parameter (>0) for ADMM. If there are convergence problems, try decreasing rho. Default n.

niter

ADMM parameter: number of iterations

sym.eps

ADMM parameter: threshold for symmetrizing with strong=TRUE

step

Stepsize for generalized gradient descent

maxiter

Maximum number of iterations for generalized gradient descent

backtrack

Backtrack parameter for generalized gradient descent

tol

Error tolerance parameter for generalized gradient descent

trace

Output option; trace=1 gives verbose output

Value

bp

p-vector of estimated "positive part" main effect (p=# features)

bn

p-vector of estimated "negative part" main effect; overall main effect estimated coefficients are bp-bn

th

Matrix of estimated interaction coefficients, of dimension p by p. Note: when output from hierNet is printed, th is symmetrized (set to (th+t(th))/2) for simplicity.

obj

Value of objective function at minimum.

lam

Value of lambda used

type

Type of model fit- "gaussian" or "logistic" (binomial)

mx

p-vector of column means of x

sx

p-vector of column standard deviations of x

my

mean of y

mzz

column means of feature product matrix

szz

column standard deviations of feature product matrix

call

The call to hierNet

References

Bien, J., Taylor, J., Tibshirani, R., (2013) "A Lasso for Hierarchical Interactions." Annals of Statistics. 41(3). 1111-1141.

See Also

predict.hierNet, hierNet.cv, hierNet.path

Examples

Run this code
# NOT RUN {
set.seed(12)
# fit a single hierNet model
x=matrix(rnorm(100*10),ncol=10)
x=scale(x,TRUE,TRUE)
y=x[,1]+2*x[,2]+ x[,1]*x[,2]+3*rnorm(100)
fit=hierNet(x,y,lam=50)
print(fit)

# try strong (rather than weak) hierarchy
fit=hierNet(x,y,lam=50, strong=TRUE)
print(fit)

# a typical analysis including cross-validation
set.seed(12)
x=matrix(rnorm(100*10),ncol=10)
x=scale(x,TRUE,TRUE)
y=x[,1]+2*x[,2]+ x[,1]*x[,2]+3*rnorm(100)
fit=hierNet.path(x,y)
fitcv=hierNet.cv(fit,x,y)
print(fitcv)

lamhat=fitcv$lamhat.1se
fit2=hierNet(x,y,lam=lamhat)
yhat=predict(fit2,x)
# }

Run the code above in your browser using DataLab