/* ** Lesson 12.2: A Nonlinear Rational Expectation Model ** GMM Estimation of Hansen-Singleton Model (Ea, 1982) */ use gpe2; output file=gpe\output12.2 reset; load x[335,3]=gpe\gmmq.txt; @ data columns: @ @ (1) c(t+1)/c(t) (2)vwr (3)rfr @ call reset; _nlopt=0; _method=5; _tol=1.0e-5; _iter=100; _b={1,0}; @ 1,0 GMM estimation with initial @ call estimate(&gmmqw,x); @ identity weighting matrix @ _b=__b; @ GMM estimation with external @ gmmw=invpd(gmmv(x,__b)); @ covariance weighting matrix @ call estimate(&gmmqw,x); call gmmout(x,__b); @ print GMM output @ _b=__b; @ there may be a convergent efficient soultion @ call estimate(&gmmq,x); @ with internal covariance weighting matrix @ call gmmout(x,__b); @ print GMM output @ end; /* User-defined moments functions, must be named mf */ proc mf(x,b); local z,n,m; n=rows(x); z=ones(n,1)~lagn(x,1); @ IV @ m=z.*(b[1]*(x[.,1]^(b[2]-1)).*x[.,2]-1); m=m~(z.*(b[1]*(x[.,1]^(b[2]-1)).*x[.,3]-1)); @ nonlinear multiple equations system @ retp(packr(m)); endp; #include gpe\gmm.gpe;