[R] re gression with multiple dependent variables?
Ben Bolker
bolker at ufl.edu
Wed Oct 28 02:57:43 CET 2009
Rnewb wrote:
>
> 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
>
It's right there in TFM ... (?lm)
If 'response' is a matrix a linear model is fitted separately by
least-squares to each column of the matrix.
Y <- cbind(y1,y2,y3)
lm(Y~...)
--
View this message in context: http://www.nabble.com/regression-with-multiple-dependent-variables--tp26088025p26088139.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list