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?

3 Answers3

4

I'm pretty sure you can do:

lm(cbind(y1,y2)~x,data=yourdata)
user603
  • 22,585
  • 3
  • 83
  • 149
JEquihua
  • 3,835
  • 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
2

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
  • 22,585
  • 3
  • 83
  • 149
  • 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