###### Example 13.7 of Greene (2012)
####################################
## Selecting the same data point and scaling income
##########
data(HealthRWM)
dat88 <- subset(HealthRWM, year==1988 & hhninc>0)
dat88$hhninc <- dat88$hhninc/10000
### A guess start
thet0 <- c(b0=log(mean(dat88$hhninc)),b1=0,b2=0,b3=0)
## Table 13.2 First column
g <- hhninc~exp(b0+b1*age+b2*educ+b3*female)
res0 <- nls(g, dat88, start=thet0, control=list(maxiter=100))
summary(res0)$coef
## Table 13.2 Second column
## Trying very hard to reproduce the results,
## Who is right?
h1 <- ~age+educ+female
model1 <- momentModel(g, h1, thet0, vcov="MDS", data=dat88)
res1 <- gmmFit(model1, control=list(reltol=1e-10, abstol=1e-10))
summary(res1)@coef
## Table 13.2 third column (close enough)
## Here a sandwich vcov is required because it is not
## efficient GMM
h2 <- ~age+educ+female+hsat+married
model2 <- momentModel(g, h2, thet0, vcov="MDS", data=dat88)
res2 <- gmmFit(model2, type="onestep")
summary(res2, sandwich=TRUE)@coef
## Table 13.2 fourth column (Can't get closer than that)
res3 <- gmmFit(model2)
summary(res3)@coef
# Lets see what happens if we start on Greene solution
update(res3, theta0=c(b0=-1.61192, b1=.00092, b2=.04647, b3=-.01517))
## No...
Run the code above in your browser using DataLab