xyz_regression: Elasticnet with interactions (glmnet)

Description Usage Arguments Value References Examples

View source: R/regression.R

Description

Elasticnet with interactions (glmnet)

Usage

1
2
xyz_regression(X, Y, lambdas = NULL, n_lambda = 10, alpha = 0.9, L = 10,
  standardize = TRUE, standardize_response = TRUE)

Arguments

X

A matrix.

Y

A vector.

lambdas

A vector of decreasing real numbers containing user specified values of lambda.

n_lambda

A natural number indicating how long the path of lambdas should be.

alpha

A real number between 0 and 1 (the elastic net parameter)

L

An integer indicating how many projection steps are performed.

standardize

A boolean indicating if X should be scaled and centered.

standardize_response

A boolean indicating if Y should be scaled and centered.

Value

N strongest interactions (of type type) between X and Y after L projections.

References

G. Thanei, N. Meinshausen and R. Shah (2016). The xyz algorithm for fast interaction search in high-dimensional data. <https://arxiv.org/pdf/1610.05108v1.pdf>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
n<-300
p<-1000
#build matrix of predictors
X<-matrix(rnorm(n*p),n,p)
#build a main effect and an interaction into Y
Y<-4*X[,1]*X[,2]-5*X[,4]+rnorm(n)
result<-xyz_regression(X,Y,n_lambda=10,alpha=0.9,L=10)
#print the result
print(result)
#plot the result
plot(result)

Example output

Lambda sequence:
lambda1=0.75502
 lambda2=0.58458
 lambda3=0.45262
 lambda4=0.35045
 lambda5=0.27134
 lambda6=0.21009
 lambda7=0.16266
 lambda8=0.12594
 lambda9=0.09751
 lambda10=0.0755
Discovered main effects: 1 Discovered interaction effects: 1
Model parameters:
intercept: -2.422749e-17
Printing effects for lambda10=0.0755
Main effects:
Main effect: 4 coefficient: -0.665061
Interaction effect:
Interaction effect: (1,2) coefficient: 0.5618248

xyz documentation built on May 2, 2019, 10:25 a.m.