Search code examples
rinstruments

R - Differences in parameter estimates and standard errors - ivreg, tsls and gmm with HAC


I have two closely related questions: 1. It seems like ivreg and tsls/gmm produce different parameter estimates:

    require(AER)
    data("CigarettesSW", package = "AER")
    CigarettesSW$rprice <- with(CigarettesSW, price/cpi)
    CigarettesSW$rincome <- with(CigarettesSW, income/population/cpi)
    CigarettesSW$tdiff <- with(CigarettesSW, (taxs - tax)/cpi)

    ## model 
   ivreg1 <- ivreg(log(packs) ~ log(rprice) + log(rincome) 
            | 1+ log(rincome) + tdiff + I(tax/cpi),
            data = CigarettesSW)

require(gmm)
tsls1 <- tsls(log(packs) ~ log(rprice) + log(rincome),
          ~   1+ log(rincome) + tdiff + I(tax/cpi),
          data = CigarettesSW)

gmm1 <- gmm(log(packs) ~ log(rprice) + log(rincome),
          ~   1+ log(rincome) + tdiff + I(tax/cpi),
            data = CigarettesSW,vcov="iid", method="2step")

xHat <- lm(log(rprice) ~ log(rincome)+ tdiff + I(tax/cpi),
           data = CigarettesSW)$fitted.values
manual2sls = lm(log(packs) ~ xHat + log(rincome) , data = CigarettesSW)

print("iid:")
print(summary(manual2sls)$coef[,1])
print(summary(ivreg1)$coef[,1:2])
print(summary(tsls1)$coef[,1:2])
print(summary(gmm1)$coef[,1:2])

ivreg and the "manual" 2 stage LS estimation produce the same parameter estimates ("ivreg1" and "manual2sls"), but tsls and the gmm procedure lead to different outcomes ("tsls1" and "gmm1"). Why is this the case? How can you ensure the same outcomes?

  1. Can you use the vcovHAC function to compute heteroscedastic and autocorrelation consistent standard errors with ivreg and/or 2sls/gmm? Why are there dissimilarities in the estimated standard errors for using HAC within gmm or afterwards?

    gmmhac <- gmm(log(packs) ~ log(rprice) + log(rincome),
              ~   1+ log(rincome) + tdiff + I(tax/cpi),
              data = CigarettesSW,vcov="HAC", method="2step")
    
    print("HAC:")
    print(coeftest(ivreg1, vcovHAC(ivreg1))[,1:2])
    print(coeftest(tsls1, vcovHAC(tsls1))[,1:2])
    try(print(print(coeftest(gmm1, vcovHAC(gmm1))[,1:2])))
    print(coeftest(gmmhac)[,1:2])
    

Many thanks in advance.


Solution

  • Looking at the gmm vignette, it looks like gmm finds the parameters numerically, which makes sense since it is used for much more general cases. Hence, the coefficients obtained by gmm will probably always be slightly different from the coefficients obtained analytically, as is the case for ivreg.

    To get robust standard errors, use e.g.

     coeftest(fm, vcov.=vcovHAC(fm))
    

    See here for a discussion of different options for robust standard errors.