Try using the "elasticnet" package instead, where I believe what you want is part of the package functionality. If I am not mistaken, elasticnet largely supercedes lars -- but (someone) please correct me if I'm wrong.
-- Bert On Tue, Mar 19, 2013 at 9:40 AM, Giovanni Giacomin <giovanni...@yahoo.com.br > wrote: > Hi, > > I'm using lars package to run some regression analysis and my doubt now is > how can I predict my model to another dataset? > Let me explain a little better: > I have a dataset from which I withhold some data. With the data that > wasn't withheld, I create the model. Now, what I'm not being able to do is > apply the model back to the data that I withheld. > Any suggestions? > > Here it goes the code: > > require(lars) > x <- as.matrix(lars.input[c(1:152)]) > y <- lars.input[,c(149)] > larsdata <- as.data.frame(cbind(y,x)) > attach(larsdata) > lars.model <- lars(x,y) > fit <- predict.lars(lars.model,x)$fit > plot(y ~ fit[,ncol(fit)]) > #so far, so good > > fit2 <- predict.lars(lars.model,withhold)$fit > plot(withhold$logBA ~ fit2[,ncol(fit2)]) > #this is when the mess shows up > > > Thanks! > > > _______________________________________________________________ > Giovanni Giacomin > Estudante de Engenharia de Agrimensura e Cartográfica - Universidade > Federal de Viçosa > Science Without Borders Student - Geography with emphasis in GIS - > University of Montana > [[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. > > -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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.