Debian Codegraph @

contrib/ms-sbvar/TZcode/MatlabFiles/a0lhgrad.m

raw
1 function [g,badg] = a0lhgrad(x0,s,nobs,nvar,a0indx);
2 %function [g,badg] = a0lhgrad(x0,s,nobs,nvar,a0indx);
3 % computes analytical gradient for use in csminwel.m
4 % x0 (parameter vector),
5 % s (covariance matrix of innovations): note divided by "nobs"
6 % nobs (no of obs),
7 % nvar (no of variables),
8 % a0indx (matrix indicating the free parameters in A0, and each column in A0 corresponds
9 % to an equation)
10 %
11 % Written by Tao Zha
12 %
13 % Copyright (C) 1997-2012 Tao Zha
14 %
15 % This free software: you can redistribute it and/or modify
16 % it under the terms of the GNU General Public License as published by
17 % the Free Software Foundation, either version 3 of the License, or
18 % (at your option) any later version.
19 %
20 % It is distributed in the hope that it will be useful,
21 % but WITHOUT ANY WARRANTY; without even the implied warranty of
22 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 % GNU General Public License for more details.
24 %
25 % If you did not received a copy of the GNU General Public License
26 % with this software, see <http://www.gnu.org/licenses/>.
27 %
28
29 %%a = zeros(nvar*nvar,1);
30 a = zeros(nvar);
31 %%g = zeros(nvar*nvar,1); % 4/27/97: not necessary. TAZ
32 badg = 0;
33 a(a0indx) = x0;
34 b = -nobs*inv(a') + nobs*s*a;
35 b = reshape(b,nvar*nvar,1);
36 g = b(a0indx);