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?
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.