title: Fitted values from the ivreg {AER} object do not match manual 2SLS results
body: <p>I'm trying to find out why fitted values from the ivreg estimation {AER} differ from manually performed 2-stage least squares (and from the appropriate reduced form equation)... the help for ivreg and ivreg.fit states that it invokes lm() repeatedly. I provide example from the {AER} package with fitted values calculated.</p>
  
  <pre><code>rm(list = ls())
  require('AER') # install.packages('AER')
  ## data and example adapted from the AER package
  data("CigarettesSW")
  CigarettesSW$rprice &lt;- with(CigarettesSW, price/cpi)
  CigarettesSW$rincome &lt;- with(CigarettesSW, income/population/cpi)
  CigarettesSW$tdiff &lt;- with(CigarettesSW, (taxs - tax)/cpi)
  
  ## Estimation by IV: log(rprice) is endogenous, tdiff is IV for log(rprice):
  fm &lt;- ivreg(log(packs) ~ log(rprice) + log(rincome) | log(rincome) + tdiff,
              data = CigarettesSW)
  ## 
  ##
  # Reduced form for log(rprice)
  rf.rprice &lt;- lm(log(rprice) ~ log(rincome) + tdiff,
                  data = CigarettesSW)
  # Reduced form for log(packs)
  rf.lpacks &lt;- lm(log(packs) ~ log(rincome) + tdiff,
                  data = CigarettesSW)
  # "Manual" 2SLS estimation of the "fm" equation
  m2sls &lt;- lm(log(packs) ~ rf.rprice$fitted.values + log(rincome),
              data = CigarettesSW)
  # Coefficients of "m2sls" are matched to "fm" object:
  summary(m2sls)
  summary(fm)
  #
  # It is my understanding, that fitted values from ivreg-fitted object "fm",
  # manually performed 2SLS (in "m2sls") and from the reduced form rf.lpacks
  # should be the same:
  #
  head(fm$fitted.values, 10)
  head(m2sls$fitted.values, 10)
  head(rf.lpacks$fitted.values, 10)
  #
  # However, fitted values from ivreg are different.
  </code></pre>
  
  <p>Most probably, I'm missing something obvious, but I'm stuck anyway. Would greatly appreciate any comments.</p>