## Stock and Watson (2007)
## data and transformations
data(CigarettesSW)
CigarettesSW$rprice <- with(CigarettesSW, price/cpi)
CigarettesSW$rincome <- with(CigarettesSW, income/population/cpi)
CigarettesSW$tdiff <- with(CigarettesSW, (taxs - tax)/cpi)
c1985 <- subset(CigarettesSW, year == "1985")
c1995 <- subset(CigarettesSW, year == "1995")
## Equation 12.15
model1 <- momentModel(log(packs)~log(rprice)+log(rincome),
~log(rincome)+tdiff, data = c1995, vcov="MDS")
res1 <- gmmFit(model1)
## HC0 robust se (different from the textbook)
summary(res1, sandwich=TRUE)
## HC1 robust se (like in the textbook)
## A little harder to get, but is it really worth it
## in the case of GMM?
summary(res1, sandwich=TRUE, df.adj=TRUE)@coef
## Equation 12.16
model2<- momentModel(log(packs)~log(rprice)+log(rincome),
~log(rincome)+tdiff+I(tax/cpi), data = c1995,
centeredVcov=FALSE, vcov="MDS")
res2<- tsls(model2)
summary(res2, sandwich=TRUE, df.adj=TRUE)
## Table 12.1
data <- data.frame(dQ=log(c1995$pack/c1985$pack),
dP=log(c1995$rprice/c1985$rprice),
dTs=c1995$tdiff-c1985$tdiff,
dT=c1995$tax/c1995$cpi-c1985$tax/c1985$cpi,
dInc=log(c1995$rincome/c1985$rincome))
model1 <- momentModel(dQ~dP+dInc, ~dInc+dTs, vcov="MDS", data=data)
model2 <- momentModel(dQ~dP+dInc, ~dInc+dT, vcov="MDS", data=data)
model3 <- momentModel(dQ~dP+dInc, ~dInc+dTs+dT, vcov="MDS", data=data)
res1 <- tsls(model1)
summary(res1, TRUE, TRUE)
res2 <- tsls(model2)
summary(res2, TRUE, TRUE)
res3 <- tsls(model3)
summary(res3, TRUE, TRUE)
Run the code above in your browser using DataLab