Dear fellow R users, I am trying to conduct a regression analysis. I have thousands of variables. The names are V1, V2,........V2000 Is there an easy way to include these variables in the regression? my model is something like that: model<- lm(y~V1+V2+.....+V2000, data=data) Thanks so much in advance, Ozlem
Ozlem, Just read ?formula, where it says: There are two special interpretations of ?.? in a formula. The usual one is in the context of a ?data? argument of model fitting functions and means ?all columns not otherwise in the formula?: see ?terms.formula?. In the context of ?update.formula?, *only*, it means ?what was previously in this part of the formula?. So, lm(y ~ . , data = data) But what do you hope to conclude from an analysis with thousands of dependent variables? Ozlem Yanmaz wrote:> Dear fellow R users, > > I am trying to conduct a regression analysis. I have thousands of > variables. The names are V1, V2,........V2000 > Is there an easy way to include these variables in the regression? > my model is something like that: > > model<- lm(y~V1+V2+.....+V2000, data=data) > > Thanks so much in advance, > > Ozlem > > ______________________________________________ > R-help at 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.
Hi, Try with ".": model<- lm(y~., data=data) From ?formula: "There are two special interpretations of |.| in a formula. The usual one is in the context of a |data| argument of model fitting functions and means 'all columns not otherwise in the formula': see |terms.formula <http://127.0.0.1:24287/library/stats/help/terms.formula>|." HTH, Ivan Le 9/22/2010 17:23, Ozlem Yanmaz a écrit :> Dear fellow R users, > > I am trying to conduct a regression analysis. I have thousands of > variables. The names are V1, V2,........V2000 > Is there an easy way to include these variables in the regression? > my model is something like that: > > model<- lm(y~V1+V2+.....+V2000, data=data) > > Thanks so much in advance, > > Ozlem > > ______________________________________________ > 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. >-- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calandra@uni-hamburg.de ********** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php [[alternative HTML version deleted]]