data(ConsumptionG)
## Get the data ready for Table 8.2 of Greene (2012)
Y <- ConsumptionG$REALDPI
C <- ConsumptionG$REALCONS
n <- nrow(ConsumptionG)
Y1 <- Y[-c(1,n)]; Y2 <- Y[-c(n-1,n)]; Y <- Y[-c(1:2)]
C1 <- C[-c(1,n)]; C <- C[-(1:2)]
dat <- data.frame(Y=Y,Y1=Y1,Y2=Y2,C=C,C1=C1)
## Starting at the NLS estimates (from the table)
theta0=c(alpha=468, beta=0.0971, gamma=1.24)
## Greene (2012) seems to assume iid errors (probably wrong assumption here)
model <- momentModel(C~alpha+beta*Y^gamma, ~C1+Y1+Y2, data=dat, theta0=theta0, vcov="iid")
### Scaling the parameters increase the speed of convergence
res <- gmmFit(model, control=list(parscale=c(1000,.1,1)))
### It also seems that there is a degree of freedom adjustment for the
### estimate of the variance of the error term.
summary(res, df.adj=TRUE)@coef
Run the code above in your browser using DataLab