


Copyright (C) 2012 Dynare Team This file is part of Dynare. Dynare is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Dynare is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Dynare. If not, see <http://www.gnu.org/licenses/>.


0001 function [vdec, corr, autocorr, z, zz] = th_moments(dr,var_list) 0002 0003 % Copyright (C) 2012 Dynare Team 0004 % 0005 % This file is part of Dynare. 0006 % 0007 % Dynare is free software: you can redistribute it and/or modify 0008 % it under the terms of the GNU General Public License as published by 0009 % the Free Software Foundation, either version 3 of the License, or 0010 % (at your option) any later version. 0011 % 0012 % Dynare is distributed in the hope that it will be useful, 0013 % but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0015 % GNU General Public License for more details. 0016 % 0017 % You should have received a copy of the GNU General Public License 0018 % along with Dynare. If not, see <http://www.gnu.org/licenses/>. 0019 0020 global M_ oo_ options_ 0021 0022 nvar = size(var_list,1); 0023 if nvar == 0 0024 nvar = length(dr.order_var); 0025 ivar = [1:nvar]'; 0026 else 0027 ivar=zeros(nvar,1); 0028 for i=1:nvar 0029 i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact'); 0030 if isempty(i_tmp) 0031 error (['One of the variable specified does not exist']) ; 0032 else 0033 ivar(i) = i_tmp; 0034 end 0035 end 0036 end 0037 0038 [gamma_y,ivar] = th_autocovariances(dr,ivar,M_, options_); 0039 m = dr.ys(ivar); 0040 0041 0042 i1 = find(abs(diag(gamma_y{1})) > 1e-12); 0043 s2 = diag(gamma_y{1}); 0044 sd = sqrt(s2); 0045 0046 0047 z = [ m sd s2 ]; 0048 mean = m; 0049 var = gamma_y{1}; 0050 0051 0052 %'THEORETICAL MOMENTS'; 0053 %'MEAN','STD. DEV.','VARIANCE'); 0054 z; 0055 0056 %'VARIANCE DECOMPOSITION (in percent)'; 0057 if M_.exo_nbr>1, 0058 vdec = 100*gamma_y{options_.ar+2}(i1,:); 0059 else 0060 vdec = 100*ones(size(gamma_y{1}(i1,1))); 0061 end 0062 %'MATRIX OF CORRELATIONS'; 0063 if options_.opt_gsa.useautocorr, 0064 corr = gamma_y{1}(i1,i1)./(sd(i1)*sd(i1)'); 0065 corr = corr-diag(diag(corr))+diag(diag(gamma_y{1}(i1,i1))); 0066 else 0067 corr = gamma_y{1}(i1,i1); 0068 end 0069 if options_.ar > 0 0070 %'COEFFICIENTS OF AUTOCORRELATION'; 0071 for i=1:options_.ar 0072 if options_.opt_gsa.useautocorr, 0073 autocorr{i} = gamma_y{i+1}(i1,i1); 0074 else 0075 autocorr{i} = gamma_y{i+1}(i1,i1).*(sd(i1)*sd(i1)'); 0076 end 0077 zz(:,i) = diag(gamma_y{i+1}(i1,i1)); 0078 end 0079 end 0080 0081 0082