📄 gobj.m
字号:
% 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, gradobj] = gobj(theta, popmom, data, W, varargin);
if nargout>1
[pmc, dpmc] = feval(popmom, theta, data, varargin{:});
else
pmc = feval(popmom, theta, data, varargin{:});
end
obs = size(pmc,1);
g = sum(pmc)';
obj = (1/obs)*g'*W*g;
if nargout>1
gradobj = 2*g'*W*dpmc;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -