Hi, I rectified my error (thanks David for pointing it out) Now I have been able to run the code:
data=read.table("data.txt", header=T) > l=data$LOSS > h=data$HPI > u=data$UE > g=data$GDP > > matrix=cbind(g,h,u) > lasso=lars(matrix,l) > The final set of coefficients for the regression is the last row of coef(lasso). Am I right? Plus what happens to the intercept estimate? It is not available in coef(lasso). Any help is welcome. Thanks, Preetam On Sat, May 4, 2013 at 9:52 PM, David Winsemius <dwinsem...@comcast.net>wrote: > > 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) > > l=data$LOSS > > h=data$HPI > > u=data$UE > > g=data$GDP > > > > matrix=data.frame(l,g,h,u) > > lasso=lars(matrix,l) > > > > 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. > > > > Thanks, > > Preetam > > -- > > Preetam Pal > > (+91)-9432212774 > > M-Stat 2nd Year, Room No. > N-114 > > Statistics Division, C.V.Raman > > Hall > > Indian Statistical Institute, B.H.O.S. > > Kolkata. > > <data.txt> > > -- > > David Winsemius > Alameda, CA, USA > > -- Preetam Pal (+91)-9432212774 M-Stat 2nd Year, Room No. N-114 Statistics Division, C.V.Raman Hall Indian Statistical Institute, B.H.O.S. Kolkata. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.