[R] re gression with multiple dependent variables?

William Dunlap wdunlap at tibco.com
Wed Oct 28 04:26:00 CET 2009


> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Rnewb
> Sent: Tuesday, October 27, 2009 6:44 PM
> To: r-help at r-project.org
> Subject: [R] re gression with multiple dependent variables?
> 
> 
> i have a series of regressions i need to run where everything 
> is the same
> except for the dependent variable, e.g.:
> 
> lm(y1 ~ x1+x2+x3+x4+x5, data=data)
> lm(y2 ~ x1+x2+x3+x4+x5, data=data)
> lm(y3 ~ x1+x2+x3+x4+x5, data=data)

You can do
   with(data, lm.fit(x=cbind(Intercept=1,x1,x2,x3), y=cbind(y1,y2,y3)))
lm.fit is the numerical code behind lm().

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> 
> is it possible to run all these regs with a single command?  
> given that the
> bulk of the work for linear regressions is inverting a matrix 
> that depends
> only on the independent variables, it seems like a waste to 
> do it over and
> over for each new dependent variable.
> 
> thanks,
> Rnewb
> -- 
> View this message in context: 
> http://www.nabble.com/regression-with-multiple-dependent-varia
bles--tp26088025p26088025.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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