Due to implemented cluster standard error methods, I'd like to estimate an instrumental variable model with felm(). With AER::ivreg() and plm::plm() I can generate the same results. Specifying the function in felm(), however, doesn't seem very straightforward to me and I've failed.
I'm using the example of the ivreg() help, where tdiff and I(tax/cpi) both are instruments for log(rprice):
library(AER)
aer.hat <- ivreg(log(packs) ~ log(rprice) + log(rincome) | log(rincome) + tdiff + I(tax/cpi),
data=CigarettesSW, subset=year == "1995")
> coef(aer.hat)
(Intercept) log(rprice) log(rincome)
9.8949555 -1.2774241 0.2804048
With plm() I could easily generate the same result:
library(plm)
plm.hat <- plm(log(packs) ~ log(rprice) + log(rincome) | log(rincome) + tdiff + I(tax/cpi),
data=CigarettesSW[CigarettesSW$year == 1995, ], model="pooling")
> coef(plm.hat)
(Intercept) log(rprice) log(rincome)
9.8949555 -1.2774241 0.2804048
But I failed with lfe::felm():
library(lfe)
felm.hat <- felm(log(packs) ~ log(rprice) + log(rincome) | 0 | log(rprice) ~ tdiff + I(tax/cpi) | 0 ,
data=CigarettesSW[CigarettesSW$year == 1995, ])
> coef(felm.hat)
(Intercept) tdiff I(tax/cpi)
1.000000e+00 -8.187404e-17 -3.294448e-17
How can we do this in felm()?
data
data("CigarettesSW", package="AER")
CigarettesSW$rprice <- with(CigarettesSW, price/cpi)
CigarettesSW$rincome <- with(CigarettesSW, income/population/cpi)
CigarettesSW$tdiff <- with(CigarettesSW, (taxs - tax)/cpi)