title: R: How to use prdict.lm() for multivariate regression
body: <p>In case of multivariate regression (multiple responses), the <code>predict.lm</code> function does not seem to work. It predicts just the first response.</p>
  
  <p><strong>Sample code:</strong></p>
  
  <pre><code>df = data_frame(x1 = c(1:20), 
                  y1 = x1 + rnorm(20,5,sd = 5), 
                  y2 = 2*x1 + rnorm(20,-5,sd = 3))
  
  
  m1 = lm(cbind(y1, y2) ~ x1, data = df)
  m1
  
  
  ## Call:
  ## lm(formula = cbind(y1, y2) ~ x1, data = df)
  
  ## Coefficients:
  ##               y1       y2     
  ## (Intercept)   7.5934  -5.9436
  ## x1            0.8704   2.0913
  </code></pre>
  
  <p>If I try to predict using this model object (for the training data or for <code>newdata</code>), it predicts only for the first response.</p>
  
  <pre><code># predicts only for y1
  length(predict.lm(m1))
  ## [1] 20 
  
  # predicts only for y1
  predict.lm(m1, newdata = data_frame(x1 = 50))
  ##        1 
  ## 51.11093
  </code></pre>
  
  <p>How can I get this function to work for multiple responses?</p>