gobj.m
来自「GMM工具箱第一部分。包含了GMM算法的各个函数」· M 代码 · 共 29 行
M
29 行
% 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 + =
减小字号Ctrl + -
显示快捷键?