2

I an trying to perform a multivariate linear regression in R.

I have two dependent variables (outcomes) and one independent variable (predictor). The model would be something like:

y1,y2~x

I did not find any way to implement this in R. Any help?

gung - Reinstate Monica
  • 132,789
  • 81
  • 357
  • 650
Cristina
  • 21
  • 1
  • 2
  • 4
    You can have a look at [Multivariate multiple regression in R](http://stats.stackexchange.com/a/11132/1909) for a walkthrough including multivariate tests. – caracal Nov 25 '12 at 19:27
  • Cristina, could you please explain exactly how your model would differ from two independent regressions `y1~x` and `y2~x`? – whuber Nov 25 '12 at 21:11
  • My dependent variables are highly correlated that's why I want to account for both of them together in the same model. – Cristina Nov 26 '12 at 13:31
  • 1
    @Cristina: do you mean a PLS 'regression'? – user603 Nov 26 '12 at 19:30
  • 1
    When both $y_1$ and $y_2$ are linearly dependent on $x$, *of course* they will be correlated to each other by virtue of those relationships. What do you want to get out of your proposed model that isn't already produced by the two separate regressions? – whuber Apr 17 '13 at 22:06

3 Answers3

3

I'm pretty sure you can do:

lm(cbind(y1,y2)~x,data=yourdata)
user603
  • 21,225
  • 3
  • 71
  • 135
JEquihua
  • 3,525
  • 2
  • 24
  • 44
  • 2
    That does two separate regressions. (Although the OP states she wants something more, I'm fine with it--she has never explained what she wants to get out of the model that isn't already in these regressions.) – whuber Apr 17 '13 at 22:05
1

lm can do that:

> y<-matrix(rnorm(100*2),100,2)
> x<-rnorm(100)
> lm(y~x)

Call:
lm(formula = y ~ x)

Coefficients:
             [,1]      [,2]    
(Intercept)  -0.18837   0.01386
x             0.25135   0.04769
user603
  • 21,225
  • 3
  • 71
  • 135
  • 3
    It seems to me that your code performs a regression for each dependent variable separately. What I want to run it's a model that account for both outcomes. – Cristina Nov 25 '12 at 19:11
  • 1
    User603's answer is correct. Given a model $Y = XB+E$ and assuming $E \sim N(0,\Sigma)$ (so you don't have a strictly diagonal covariance matrix) the maximum likelihood estimator for $B$ is simply $B_{OLS} = (X^T X)^{-1} X^T Y$, which amounts in performing separate ordinary least squares estimates for each of the q response variables and does not depend on $\Sigma$. ($\Sigma$ appears as $\Omega^{-1}$ in the literature sometimes, $\Omega$ being the precision matrix) – usεr11852 Apr 18 '13 at 02:16
-2

A Multivariate Response model could be more accurate and powerful than 2 Univariate response model because it will use the correlation between the 2 or more dependent variables to improve the prediction on each of the dependent variable. A complete description of existing methods and a new approach are described in this paper by Breiman and Friedman (2002). However I haven't tried them with R yet. I found the article available for free download here http://onlinelibrary.wiley.com/doi/10.1111/1467-9868.00054/pdf

MrDM
  • 1
  • 1
    I can't download that article, care to upload it somewhere else? Anyway, how would such a model be constructed? The OP is curiously silent on what she actually wants to do with the variables – IMA Apr 23 '13 at 13:42
  • This is not an answer to the question. Also link is to the paid website. – sashkello Apr 23 '13 at 13:45