⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gobj.m

📁 GMM工具箱第一部分。包含了GMM算法的各个函数
💻 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 + -