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:


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

  • 4
    $\begingroup$ You can have a look at Multivariate multiple regression in R for a walkthrough including multivariate tests. $\endgroup$
    – caracal
    Commented Nov 25, 2012 at 19:27
  • $\begingroup$ Cristina, could you please explain exactly how your model would differ from two independent regressions y1~x and y2~x? $\endgroup$
    – whuber
    Commented Nov 25, 2012 at 21:11
  • $\begingroup$ My dependent variables are highly correlated that's why I want to account for both of them together in the same model. $\endgroup$
    – Cristina
    Commented Nov 26, 2012 at 13:31
  • 1
    $\begingroup$ @Cristina: do you mean a PLS 'regression'? $\endgroup$
    – user603
    Commented Nov 26, 2012 at 19:30
  • 1
    $\begingroup$ 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? $\endgroup$
    – whuber
    Commented Apr 17, 2013 at 22:06

3 Answers 3


I'm pretty sure you can do:

  • 2
    $\begingroup$ 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.) $\endgroup$
    – whuber
    Commented Apr 17, 2013 at 22:05

lm can do that:

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

lm(formula = y ~ x)

             [,1]      [,2]    
(Intercept)  -0.18837   0.01386
x             0.25135   0.04769
  • 3
    $\begingroup$ 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. $\endgroup$
    – Cristina
    Commented Nov 25, 2012 at 19:11
  • 1
    $\begingroup$ 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) $\endgroup$
    – usεr11852
    Commented Apr 18, 2013 at 2:16

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

  • 1
    $\begingroup$ 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 $\endgroup$
    – IMA
    Commented Apr 23, 2013 at 13:42
  • $\begingroup$ This is not an answer to the question. Also link is to the paid website. $\endgroup$
    – sashkello
    Commented Apr 23, 2013 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.