[R] too many var in lm

Doran, Harold HDoran at air.org
Wed Aug 17 15:38:30 CEST 2011


I'm not sure this is the most elegant way. See ?formula for the canonical way of doing this in R. However, I am hoping you're not fitting a model with more than 2,000 predictors, are you? If so, ummm, wow. 

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
> Behalf Of R. Michael Weylandt
> Sent: Wednesday, August 17, 2011 9:28 AM
> To: carol white
> Cc: r-help at stat.math.ethz.ch
> Subject: Re: [R] too many var in lm
> 
> The most elegant solution is going to depend on where you data comes from,
> but one way to do it if you have a matrix of data:
> 
> D = cbind(rcauchy(100), matrix(runif(100*50),ncol=50)) # Some nonsense data
> lm(D[,1] ~ D[,-1])
> 
> If you let us know how your data is set up, a more specific response can be
> given.
> 
> Hope this helps,
> 
> Michael Weylandt
> 
> On Wed, Aug 17, 2011 at 9:23 AM, carol white <wht_crl at yahoo.com> wrote:
> 
> > Hello,
> > It might be an easy question but if you have many variables to fit in the
> > lm function, how do you take all without specifying var1+var2+...+var2100 in
> > the terms parameter in response ~ terms?
> >
> > Cheers,
> >
> > Carol
> >
> > ______________________________________________
> > 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.
> >
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.



More information about the R-help mailing list