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']
%
thetg = theta(1);
cons = theta(2);
thet = .3;
beta = .96;
H = [xgmm(:,1)-thet*xgmm(:,2)-(1-thet)*xgmm(:,3)-thetg*xgmm(:,4)-cons];
if nargout>1;
nt=length(xgmm);
dH=[-xgmm(:,4),-ones(nt,1)];
end;