On Tue, 2011-07-12 at 10:12 -0400, Heiman, Thomas J. wrote: > Hi, > > Hopefully I got the formatting down.. I am trying to do a lasso regression > using the lars package with the following data (the data files is in .csv > format): > > V1 V2 V3 V4 > V5 V6 V7 V8 V9 > 1 FastestTime WinPercentage PlacePercentage ShowPercentage > BreakAverage FinishAverage Time7Average Time3Average Finish > 2 116.9 0.14285715 0.14285715 0.2857143 > 4.428571 3.2857144 117.557144 117.76667 5.0 > 3 116.22857 0.2857143 0.42857143 0.14285715 > 6.142857 2.142857 116.84286 116.8 2.0 > 4 116.41428 0.0 0.14285715 0.2857143 > 5.714286 3.7142856 117.24286 117.166664 4.0 > 5 115.8 0.5714286 0.0 0.2857143 > 2.142857 2.5714285 116.21429 116.53333 6.0 > > #load Data > crs<- > read.csv("file:///C:/temp/Horse//horseracing.csv<file:///C:\temp\Horse\horseracing.csv>", > na.strings=c(",", "NA", "", "?"), encoding="UTF-8") > > # # define x and y > x= x<-crs[,9] #predictor variables > y= y<-crs[1:8,] #response variable > > > library(lars) > cv.lars(x, y, K=10, trace=TRUE, plot.it = TRUE,se = TRUE, type="lasso") > > and I get: > > LASSO sequence > Error in one %*% x : requires numeric/complex matrix/vector arguments > > Any idea on what I am doing wrong? Thank you!!
Row 1 contains character data, the variable names. Are you missing a `header = TRUE` (this is the default in `read.csv()`), or do you have several header lines? I also think you have the response/predictors back to front there; otherwise, why would you need to shrink the coefficient and select from a model with a single predictor? HTH G > Sincerely, > > tom > > ______________________________________________ > 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. -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% ______________________________________________ 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.