[R] re gression with multiple dependent variables?

Daniel Malter daniel at umd.edu
Wed Oct 28 04:17:25 CET 2009


Hi, cbind the dependent variables such as in:

x=rnorm(100)
e1=rnorm(100)
e2=rnorm(100)
e3=rnorm(100)

y1=2*x+e1
y2=-1*x+e2
y3=0.7*x+e3

reg=lm(cbind(y1,y2,y3)~x)
summary(reg)

Cheers,
Daniel 


-------------------------
cuncta stricte discussurus
-------------------------

-----Ursprüngliche Nachricht-----
Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im
Auftrag von Rnewb
Gesendet: Tuesday, October 27, 2009 9:44 PM
An: r-help at r-project.org
Betreff: [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)

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-variables--tp260880
25p26088025.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