1function of = a0lhfun(x,s,nobs,nvar,a0indx)
2% of = a0lhfun(x,s,nobs,nvar,a0indx) -- negative logLH
3%          Note: columns correpond to equations
4% general program to setup A0 matrix and compute the likelihood
5% requires
6%  x (parameter vector),
7%  s (covariance matrix of innovations): note already divided by "nobs"
8%  nobs (no of obs),
9%  nvar (no of variables),
10%  a0indx (matrix indicating the free parameters in A0, and each column in A0 corresponds
11%                    to an equation)
12% written by Eric Leeper
13%
14% Copyright (C) 1997-2012 Eric Leeper
15%
16% This free software: you can redistribute it and/or modify
17% it under the terms of the GNU General Public License as published by
18% the Free Software Foundation, either version 3 of the License, or
19% (at your option) any later version.
20%
21% It is distributed in the hope that it will be useful,
22% but WITHOUT ANY WARRANTY; without even the implied warranty of
23% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24% GNU General Public License for more details.
25%
26% If you did not received a copy of the GNU General Public License
27% with this software, see <http://www.gnu.org/licenses/>.
28%
29
30
31a0 = zeros(nvar);
32a0(a0indx) = x;
33% Note: each column in a0 corresponds to an equation!!
34%
35%%ada = chol(a0'*a0);
36%%ada = log(abs(diag(ada)));
37%%ada = sum(ada);
38% **  TZ, 10/15/96, the above two lines can be improved by the following three lines
39[a0l,a0u] = lu(a0);
40%ada=diag(abs(a0u));
41%ada=sum(log(ada));
42ada = sum(log(abs(diag(a0u))));
43
44%
45%tra = trace(a0'*s*a0);
46tra = reshape(s,nvar*nvar,1)'*reshape(a0*a0',nvar*nvar,1);
47%if ada == 0
48%   of = 1.0;
49%   else
50%   of = -nobs*ada + nobs*.5*tra;
51%end
52% commented out by T.Z. for there appears no sense of using "if-end"
53
54
55of = -nobs*ada + nobs*.5*tra;
56