| 1 |
function g = a0lhgh(x0,s,nobs,nvar,a0indx); |
| 2 |
%function g = a0lhgh(x0,s,nobs,nvar,a0indx); |
| 3 |
% computes the hessian with analytical gradient provided |
| 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 |
% Copyright (C) 1997-2012 Tao Zha |
| 12 |
% |
| 13 |
% This free software: you can redistribute it and/or modify |
| 14 |
% it under the terms of the GNU General Public License as published by |
| 15 |
% the Free Software Foundation, either version 3 of the License, or |
| 16 |
% (at your option) any later version. |
| 17 |
% |
| 18 |
% It is distributed in the hope that it will be useful, |
| 19 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 |
% GNU General Public License for more details. |
| 22 |
% |
| 23 |
% If you did not received a copy of the GNU General Public License |
| 24 |
% with this software, see <http://www.gnu.org/licenses/>. |
| 25 |
% |
| 26 |
|
| 27 |
%%a = zeros(nvar*nvar,1); |
| 28 |
a = zeros(nvar); |
| 29 |
g = zeros(nvar*nvar,1); |
| 30 |
badg = 0; |
| 31 |
a(a0indx) = x0; |
| 32 |
b = -nobs*inv(a') + nobs*s*a; |
| 33 |
b = reshape(b,nvar*nvar,1); |
| 34 |
g = b(a0indx); |