forked from tholden/gmmtbx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgobj.m
25 lines (23 loc) · 907 Bytes
/
gobj.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
% GOBJ: Computes the GMM objective function and its gradient
%
% SYNTAX: [obj, gradobj]=gobj(theta, popmom, data, W, varargin);
%
% INPUT
% theta : A vector with the estimated parameters.
% popmom : An m-file that calculates the moment conditions and its gradient.
% The file must be of the type: [mom, gradmom] = popmom(data, theta, varargin)
% data : A matrix containing the dataset used for estimation.
% W : The weighting matrix used for calculating the objective function
% [varargin]: Additional parameters passed to the popmom function
%
% OUTPUT
% obj : The value of the GMM objective function.
% gradobj: The gradient of the objective function.
function obj = gobj(theta, popmom, data, W, varargin)
pmc = popmom( theta, data, varargin{:});
obs = size(pmc,1);
g = sum(pmc)';
obj = (1/obs)*g'*W*g;
% if nargout>1
% gradobj = 2*g'*W*dpmc;
% end