function [H,dH]=gmmh(theta); %GMMH A user-supplied function for GMM estimation. % [H,dH]=gmmh(theta) is called by GMM and GMMJ. H is a % nobs x m (or mgmm) matrix with rows containing the m x 1 % vectors h(x(t+n),theta), where it is assumed that % % E[ h(x(t+n),theta) | I(t) ] = 0, t=1,...,nobs. % % dH is a nobs x (m*l) matrix containing the derivatives % of H with respect to the elements of theta, i.e. % dH(t,:)= [dh1(x(t+n),theta)/dtheta', ... % dhm(x(t+n),theta)/dtheta'] % % Code for H, dH from example in: % Hansen, L.P. and K.J. Singleton, "Generalized Instrumental % Variables Estimation of Nonlinear Rational Expectations % Models," ECONOMETRICA, 50:1269-1286, 1982, pp. 1281-1282. % beta = theta(1); alpha = theta(2); H=beta*xgmm(:,1).^alpha.*xgmm(:,2)-1; if nargout>1; dH=[(H+1)/beta,(H+1).*log(xgmm(:,1))]; end;