least angler regression code

Download least angler regression code

If you can't read please download the document

Upload: prabinseth

Post on 08-Sep-2015

5 views

Category:

Documents


2 download

DESCRIPTION

least angle regression code

TRANSCRIPT

# EXAMPLEsource('B-RLARS.R') # loads the function 'rlars()' (and auxiliary functions) ## Example 1## Generation of data for the ExampleX = matrix(rnorm(1000),100,10) # creates 10 candidate predictorsy = X[,1]+X[,2]+X[,3] + rnorm(100) # creates 3 "target" predictors (columns 1, 2 and 3)# B-LARS analysisbrlars(X,y) # ranks the candidate predictorsbrlars(X,y,m=10,mm=5) # ranks the candidate predictors, sequencing only the # first 5 predictors in each bootstrap sample brlars(X,y,m=5,mm=5,dB=7) # ranks the candidate predictors, sequencing only # the first 5 predictors in each bootstrap sample # and feeding only the top 7 candidate predictors # to the bootstrap samples brlars(X,y,B=0) # Basic RLARS procedure without bootstrapres = brlars(X,y)$active # stores in "res' the ranked sequence of predictorsres ## Example 2: High dimensional data## Generation of data for the ExampleX = matrix(rnorm(3000),50,60) # creates 60 candidate predictorsy = X[,1]+X[,2]+X[,3] + rnorm(50) # creates 3 "target" predictors (columns 1, 2 and 3)## B-RLARS examplebrlars(X,y) # ranks the first 49 predictorsbrlars(X,y,mm=20) # ranks the first 49 predictors, sequencing only the # first 20 predictors in each bootstrap sample brlars(X,y,m=20,mm=10) # ranks the first 20 predictors, sequencing only the # first 10 predictors in each bootstrap sample brlars(X,y,m=20,mm=10, dB=20) # ranks the first 20 predictors, sequencing only the # first 10 predictors in each bootstrap sample # and feeding only the top 20 candidate predictors # to the bootstrap samples brlars(X,y,B=0) # Basic RLARS procedure without bootstrap