| 1 |
function [Ptld,H0invtld,Hpinvtld] = rlrprior(Ui,Vi,Pi,H0multi,Hpmulti,nvar) |
| 2 |
% [Ptld,H0invtld,Hpinvtld] = rlrprior(Ui,Vi,Pi,H0multi,Hpmulti,nvar) |
| 3 |
% |
| 4 |
% Exporting random Bayesian prior with linear restrictions |
| 5 |
% See Waggoner and Zha's Gibbs sampling paper |
| 6 |
% |
| 7 |
% Ui: nvar-by-1 cell. In each cell, nvar-by-qi orthonormal basis for the null of the ith |
| 8 |
% equation contemporaneous restriction matrix where qi is the number of free parameters. |
| 9 |
% With this transformation, we have ai = Ui*bi or Ui'*ai = bi where ai is a vector |
| 10 |
% of total original parameters and bi is a vector of free parameters. When no |
| 11 |
% restrictions are imposed, we have Ui = I. There must be at least one free |
| 12 |
% parameter left for the ith equation. Imported from dnrprior.m. |
| 13 |
% Vi: nvar-by-1 cell. In each cell, k-by-ri orthonormal basis for the null of the ith |
| 14 |
% equation lagged restriction matrix where k (ncoef) is a total number of RHS variables and |
| 15 |
% ri is the number of free parameters. With this transformation, we have fi = Vi*gi |
| 16 |
% or Vi'*fi = gi where fi is a vector of total original parameters and gi is a |
| 17 |
% vector of free parameters. There must be at least one free parameter left for |
| 18 |
% the ith equation. Imported from dnrprior.m. |
| 19 |
% Pi: ncoef-by-nvar matrix for the ith equation under random walk. Same for all equations |
| 20 |
% H0multi: nvar-by-nvar-by-nvar; H0 for different equations under asymmetric prior |
| 21 |
% Hpmulti: ncoef-by-ncoef-by-nvar; H+ for different equations under asymmetric prior |
| 22 |
% nvar: number of endogenous variables |
| 23 |
% -------------------- |
| 24 |
% Ptld: cell(nvar,1), linear transformation for random walk prior for the ith equation |
| 25 |
% H0invtld: cell(nvar,1), transformed inv covaraince for free parameters in A0(:,i). |
| 26 |
% Hpinvtld: cell(nvar,1), transformed inv covaraince for free parameters in A+(:,i); |
| 27 |
% |
| 28 |
% Tao Zha, February 2000 |
| 29 |
% |
| 30 |
% Copyright (C) 1997-2012 Tao Zha |
| 31 |
% |
| 32 |
% This free software: you can redistribute it and/or modify |
| 33 |
% it under the terms of the GNU General Public License as published by |
| 34 |
% the Free Software Foundation, either version 3 of the License, or |
| 35 |
% (at your option) any later version. |
| 36 |
% |
| 37 |
% It is distributed in the hope that it will be useful, |
| 38 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 39 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 40 |
% GNU General Public License for more details. |
| 41 |
% |
| 42 |
% If you did not received a copy of the GNU General Public License |
| 43 |
% with this software, see <http://www.gnu.org/licenses/>. |
| 44 |
% |
| 45 |
|
| 46 |
Ptld = cell(nvar,1); % tld: tilda |
| 47 |
H0invtld = cell(nvar,1); % H0 for different equations under linear restrictions |
| 48 |
Hpinvtld = cell(nvar,1); % H+ for different equations under linear restrictions |
| 49 |
|
| 50 |
for n=1:nvar % one for each equation |
| 51 |
Hpinvtld{n} = Vi{n}'*(Hpmulti(:,:,n)\Vi{n}); |
| 52 |
Ptld{n} = (Hpinvtld{n}\Vi{n}')*(Hpmulti(:,:,n)\Pi)*Ui{n}; |
| 53 |
H0invtld{n} = Ui{n}'*(H0multi(:,:,n)\Ui{n}) + Ui{n}'*Pi'*(Hpmulti(:,:,n)\Pi)*Ui{n} ... |
| 54 |
- Ptld{n}'*Hpinvtld{n}*Ptld{n}; |
| 55 |
end |