0

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.

berter
  • 23
  • 5
  • 1
    `gmm::tsls` does not have an option `method`, and hence no option to specify `method="2step"`. Any chance you could make your example reproducable? – coffeinjunky Jun 08 '16 at 15:06
  • Yes, you are right. I removed this from the code. Is the example not reproducable? It's just an "extended" example one from `?ivreg`. – berter Jun 08 '16 at 15:17
  • Also, looking at `?tsls`, you find that `The function just calls gmm with the option vcov="iid".` So, it is not really a surprise that your call to `tsls` and to `gmm` give identical results... – coffeinjunky Jun 08 '16 at 15:17
  • That's a fair point (Thanks, I was not aware of this). But if I want to use `vcovHAC` (in the part 2.), it seems that for `tsls` it is possible to use it, however for `gmm` not. – berter Jun 08 '16 at 15:22
  • Just to clarify, why would you not want to use `vcov="HAC"` as opposed to `vcov="iid"` in the call to `gmm` if you want to have `HAC` anyway? – coffeinjunky Jun 08 '16 at 15:31
  • I tried to use this option (estimate `gmm` with iid and then compute the `vcov` with `HAC`) so that `gmm` may not update the parameter estimation internally and the estimates would be the same as for `ivreg`. Actually, all three ways should lead to the same outcomes, right? So this is `gmmhac` and `coeftest(gmm1, vcovHAC(gmm1))` and `coeftest(ivreg1, vcovHAC(ivreg1)` should produce the same outcomes. – berter Jun 08 '16 at 15:36
  • Well, it looks like `gmm` obtains the parameter values numerically, so there will always be some discrepancy to the analytical solution obtained in the manual way or by `ivreg`. Why not just use `ivreg`? – coffeinjunky Jun 08 '16 at 15:40
  • Ok, so this should solve the first part. It is save/possible to use `vcovHAC` for `ivreg` and/or `gmm`? If you look at the `estfun` in `vcovHAC` is seems to me that the instrumental variables are not considered? So this may explain the discrepancy of the outcomes of `gmmhac` and `coeftest(ivreg1, vcovHAC(ivreg1)`? – berter Jun 08 '16 at 15:50

1 Answers1

1

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.

Community
  • 1
  • 1
coffeinjunky
  • 11,254
  • 39
  • 57
  • Ok, so this should solve the first part. It is save/possible to use `vcovHAC` for `ivreg` and/or `gmm`? If you look at the `estfun` in `vcovHAC` is seems to me that the instrumental variables are not considered? So this may explain the discrepancy of the outcomes of `gmmhac` and `coeftest(ivreg1, vcovHAC(ivreg1)`? – berter Jun 08 '16 at 15:54
  • I would be surprised if `sandwich` did not work properly with IVs, but I am not sure. You could probably create some simple test cases and see what comes out. Why not do that? – coffeinjunky Jun 08 '16 at 16:00
  • Yes, I should do that to find out the differences (of `gmmhac` and `coeftest(ivreg1, vcovHAC(ivreg1)`). Thanks for your advice. – berter Jun 08 '16 at 17:24
  • I think its better to ask the second question separatly and mark this question as answered. – berter Jun 13 '16 at 13:41
  • This is the link to the new question (i.e., the speparated second part from above) [link](http://stackoverflow.com/questions/37792661/r-is-it-save-to-use-the-package-sandwich-for-instrumental-variable-or-gmm-model) – berter Jun 13 '16 at 14:43