Home > matlab > mult_elimination.m

mult_elimination

PURPOSE ^

function mult_elimination()

SYNOPSIS ^

function dr=mult_elimination(varlist,M_, options_, oo_)

DESCRIPTION ^

 function mult_elimination()
 replaces Lagrange multipliers in Ramsey policy by lagged value of state
 and shock variables

 INPUT
   none  

 OUTPUT
   dr: a structure with the new decision rule

 SPECIAL REQUIREMENTS
   none

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function dr=mult_elimination(varlist,M_, options_, oo_)
0002 % function mult_elimination()
0003 % replaces Lagrange multipliers in Ramsey policy by lagged value of state
0004 % and shock variables
0005 %
0006 % INPUT
0007 %   none
0008 %
0009 % OUTPUT
0010 %   dr: a structure with the new decision rule
0011 %
0012 % SPECIAL REQUIREMENTS
0013 %   none
0014 
0015 % Copyright (C) 2003-2011 Dynare Team
0016 %
0017 % This file is part of Dynare.
0018 %
0019 % Dynare is free software: you can redistribute it and/or modify
0020 % it under the terms of the GNU General Public License as published by
0021 % the Free Software Foundation, either version 3 of the License, or
0022 % (at your option) any later version.
0023 %
0024 % Dynare is distributed in the hope that it will be useful,
0025 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0026 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0027 % GNU General Public License for more details.
0028 %
0029 % You should have received a copy of the GNU General Public License
0030 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0031 
0032 dr = oo_.dr;
0033 
0034 nstatic = dr.nstatic;
0035 npred = dr.npred;
0036 order_var = dr.order_var;
0037 nstates = M_.endo_names(order_var(nstatic+(1:npred)),:);
0038 
0039 il = strmatch('MULT_',nstates);
0040 nil = setdiff(1:dr.npred,il);
0041 m_nbr = length(il);
0042 nm_nbr = length(nil);
0043 
0044 AA1 = dr.ghx(:,nil);
0045 AA2 = dr.ghx(:,il);
0046 A1 = dr.ghx(nstatic+(1:npred),nil);
0047 A2 = dr.ghx(nstatic+(1:npred),il);
0048 B = dr.ghu(nstatic+(1:npred),:);
0049 A11 = A1(nil,:);
0050 A21 = A1(il,:);
0051 A12 = A2(nil,:);
0052 A22 = A2(il,:);
0053 B1 = B(nil,:);
0054 B2 = B(il,:);
0055 
0056 [Q1,R1,E1] = qr([A12; A22]);
0057 n1 = sum(abs(diag(R1)) > 1e-8);
0058 
0059 Q1_12 = Q1(1:nm_nbr,n1+1:end);
0060 Q1_22 = Q1(nm_nbr+(1:m_nbr),n1+1:end);
0061 [Q2,R2,E2] = qr(Q1_22');
0062 n2 = sum(abs(diag(R2)) > 1e-8);
0063 
0064 R2_1 = inv(R2(1:n2,1:n2));
0065 
0066 M1 = AA1 - AA2*E2*[R2_1*Q2(:,1:n2)'*Q1_12'; zeros(m_nbr-n2,nm_nbr)];
0067 M2 = AA2*E2*[R2_1*Q2(:,1:n2)'*[Q1_12' Q1_22']*[A11;A21]; zeros(m_nbr-n2,length(nil))];
0068 M3 = dr.ghu;
0069 M4 = AA2*E2*[R2_1*Q2(:,1:n2)'*[Q1_12' Q1_22']*[B1;B2]; zeros(m_nbr-n2,size(B,2))];
0070 
0071 k1 = nstatic+(1:npred);
0072 k1 = k1(nil);
0073 
0074 endo_nbr = M_.orig_endo_nbr;
0075 exo_nbr = M_.exo_nbr;
0076 
0077 lead_lag_incidence = M_.lead_lag_incidence(:,1:endo_nbr+exo_nbr);
0078 lead_lag_incidence1 = lead_lag_incidence(1,:) > 0;
0079 maximum_lag = M_.maximum_lag;
0080 for i=1:maximum_lag-1
0081     lead_lag_incidence1 = [lead_lag_incidence1; lead_lag_incidence(i,:)| ...
0082                         lead_lag_incidence(i+1,:)];
0083 end
0084 lead_lag_incidence1 = [lead_lag_incidence1; ...
0085                     lead_lag_incidence(M_.maximum_lag,:) > 0];
0086 k = find(lead_lag_incidence1');
0087 lead_lag_incidence1 = zeros(size(lead_lag_incidence1'));
0088 lead_lag_incidence1(k) = 1:length(k);
0089 lead_lag_incidence1 = lead_lag_incidence1';
0090 
0091 kstate = zeros(0,2);
0092 for i=maximum_lag:-1:1
0093     k = find(lead_lag_incidence(i,:));
0094     kstate = [kstate; [k' repmat(i+1,length(k),1)]];
0095 end
0096 
0097 dr.M1 = M1;
0098 dr.M2 = M2;
0099 dr.M3 = M3;
0100 dr.M4 = M4;
0101 
0102 nvar = length(varlist);
0103 nspred = dr.nspred;
0104 
0105 if nvar > 0 && options_.noprint == 0
0106     res_table = zeros(2*(nm_nbr+M_.exo_nbr),nvar);
0107     headers = 'Variables';
0108     for i=1:length(varlist)
0109         k = strmatch(varlist{i},M_.endo_names(dr.order_var,:),'exact');
0110         headers = char(headers,varlist{i});
0111         
0112         res_table(1:nm_nbr,i) = M1(k,:)';
0113         res_table(nm_nbr+(1:nm_nbr),i) = M2(k,:)';
0114         res_table(2*nm_nbr+(1:M_.exo_nbr),i) = M3(k,:)';
0115         res_table(2*nm_nbr+M_.exo_nbr+(1:M_.exo_nbr),i) = M4(k,:)';
0116     end
0117     
0118     my_title='ELIMINATION OF THE MULTIPLIERS';
0119     lab = nstates(nil,:);
0120     labels = strcat(deblank(lab(i,:)),'(-1)');
0121     for i = 2:size(lab,1)
0122         labels = char(labels,strcat(deblank(lab(i,:)),'(-1)'));
0123     end
0124     for i = 1:size(lab,1)
0125         labels = char(labels,strcat(deblank(lab(i,:)),'(-2)'));
0126     end
0127     labels = char(labels,M_.exo_names);
0128     for i = 1:M_.exo_nbr
0129         labels = char(labels,strcat(deblank(M_.exo_names(i,:)),'(-1)'));
0130     end
0131     lh = size(labels,2)+2;
0132     dyntable(my_title,headers,labels,res_table,lh,10,6);
0133     disp(' ')
0134 end

Generated on Tue 22-May-2012 02:40:23 by m2html © 2005