[R] Lasso Regression error
dwinsemius at comcast.net
Sat May 4 18:22:35 CEST 2013
On May 4, 2013, at 6:09 AM, Preetam Pal wrote:
> Hi all,
> I have a data set containing variables LOSS, GDP, HPI and UE.
> (I have attached it in case it is required).
> Having renamed the variables as l,g,h and u, I wish to run a Lasso
> Regression with l as the dependent variable and all the other 3 as the
> independent variables.
> data=read.table("data.txt", header=T)
> But R is throwing an error (shown below) at this:
> Error in rep(1, n) : invalid 'times' argument
I get a different error using package:lars version 1.1 but the problem is likely that same. You created an object named `matrix` which is not a matrix. You apparently expected `lars` to recognize your intent. It didn't. (You also included your response variable in your set of predictors. `lars` will run this without error, but treats it like a tautology. ) Try offering the types of R objects that `lars` is documented to accept.
> Can you kindly suggest where I went wrong?
> [Just wanted to mention that I am getting the same error when instead of
> the matrix of predictor variables, I am using only a single variable, say,
> g : lasso=lars(g,l)]
> Appreciate any help.
> Preetam Pal
> M-Stat 2nd Year, Room No. N-114
> Statistics Division, C.V.Raman
> Indian Statistical Institute, B.H.O.S.
Alameda, CA, USA
More information about the R-help