Debian Codegraph @

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

raw
1 function [Fmat,gvec] = fn_gfmean(b,P,Vi,nvar,ncoef,n0,np)
2 % [Fmat,gvec] = fn_gfmean(b,P,Vi,nvar,ncoef,n0,np)
3 %
4 % Mean of free lagged parameters g and original lagged parameters F, conditional on comtemporaneous b's
5 % See Waggoner and Zha's Gibbs sampling
6 %
7 % b: sum(n0)-element vector of mean estimate of A0 free parameters
8 % P: cell(nvar,1). In each cell, the transformation matrix that affects the posterior mean of A+ conditional on A0.
9 % Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith
10 % equation lagged restriction matrix where k is a total of exogenous variables and
11 % ri is the number of free parameters. With this transformation, we have fi = Vi*gi
12 % or Vi'*fi = gi where fi is a vector of total original parameters and gi is a
13 % vector of free parameters. There must be at least one free parameter left for
14 % the ith equation.
15 % nvar: number of endogeous variables
16 % ncoef: number of original lagged variables per equation
17 % n0: nvar-element vector, ith element represents the number of free A0 parameters in ith equation
18 % np: nvar-element vector, ith element represents the number of free A+ parameters in ith equation
19 %---------------
20 % Fmat: ncoef-by-nvar matrix of original lagged parameters A+. Column corresponding to equation.
21 % gvec: sum(np)-by-1 stacked vector of all free lagged parameters A+.
22 %
23 % Tao Zha, February 2000. Revised, August 2000.
24 %
25 % Copyright (C) 1997-2012 Tao Zha
26 %
27 % This free software: you can redistribute it and/or modify
28 % it under the terms of the GNU General Public License as published by
29 % the Free Software Foundation, either version 3 of the License, or
30 % (at your option) any later version.
31 %
32 % It is distributed in the hope that it will be useful,
33 % but WITHOUT ANY WARRANTY; without even the implied warranty of
34 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 % GNU General Public License for more details.
36 %
37 % If you did not received a copy of the GNU General Public License
38 % with this software, see <http://www.gnu.org/licenses/>.
39 %
40
41
42 b=b(:); n0=n0(:); np=np(:);
43
44 n0cum = [0;cumsum(n0)];
45 npcum = [0;cumsum(np)];
46 gvec = zeros(npcum(end),1);
47 Fmat = zeros(ncoef,nvar); % ncoef: maximum original lagged parameters per equation
48
49 if ~(length(b)==n0cum(end))
50 error('Make inputs n0 and length(b) match exactly')
51 end
52
53 for kj=1:nvar
54 bj = b(n0cum(kj)+1:n0cum(kj+1));
55 gj = P{kj}*bj;
56 gvec(npcum(kj)+1:npcum(kj+1)) = gj;
57 Fmat(:,kj) = Vi{kj}*gj;
58 end