R - 参数估计和标准误差的差异 - ivreg,tsls和gmm与HAC

时间:2016-06-08 14:51:09

标签: r instruments

我有两个密切相关的问题: 似乎ivreg和tsls / gmm产生了不同的参数估计值:

    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和“手动”2阶段LS估计产生相同的参数估计(“ivreg1”和“manual2sls”), 但是tsls和gmm程序导致不同的结果(“tsls1”和“gmm1”)。为什么会这样? 你怎么能确保相同的结果?

  1. 您可以使用vcovHAC函数计算ivos和/或2sls / gmm的异方差和自相关一致标准误差吗?为什么在gmm内或之后使用HAC的估计标准误差存在差异?

    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])
    
  2. 非常感谢提前。

1 个答案:

答案 0 :(得分:1)

查看gmm vignette,看起来gmm以数字方式查找参数,这很有意义,因为它用于更一般的情况。因此,gmm获得的系数可能总是与分析得到的系数略有不同,如ivreg的情况。

要获得强大的标准错误,请使用例如

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

有关强大标准错误的不同选项的讨论,请参阅here