Home > matlab > compute_moments_varendo.m

compute_moments_varendo

PURPOSE ^

Computes the second order moments (autocorrelation function, covariance

SYNOPSIS ^

function oo_ = compute_moments_varendo(type,options_,M_,oo_,var_list_)

DESCRIPTION ^

 Computes the second order moments (autocorrelation function, covariance
 matrix and variance decomposition) distributions for all the endogenous variables selected in
 var_list_. The results are saved in oo_
  
 INPUTS:
   type            [string]       'posterior' or 'prior'
   options_        [structure]    Dynare structure.
   M_              [structure]    Dynare structure (related to model definition).
   oo_             [structure]    Dynare structure (results).
   var_list_       [string]       Array of string with endogenous variable names.
    
 OUTPUTS
   oo_             [structure]    Dynare structure (results).

 SPECIAL REQUIREMENTS
   none

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function oo_ = compute_moments_varendo(type,options_,M_,oo_,var_list_)
0002 % Computes the second order moments (autocorrelation function, covariance
0003 % matrix and variance decomposition) distributions for all the endogenous variables selected in
0004 % var_list_. The results are saved in oo_
0005 %
0006 % INPUTS:
0007 %   type            [string]       'posterior' or 'prior'
0008 %   options_        [structure]    Dynare structure.
0009 %   M_              [structure]    Dynare structure (related to model definition).
0010 %   oo_             [structure]    Dynare structure (results).
0011 %   var_list_       [string]       Array of string with endogenous variable names.
0012 %
0013 % OUTPUTS
0014 %   oo_             [structure]    Dynare structure (results).
0015 %
0016 % SPECIAL REQUIREMENTS
0017 %   none
0018 
0019 % Copyright (C) 2008-2010 Dynare Team
0020 %
0021 % This file is part of Dynare.
0022 %
0023 % Dynare is free software: you can redistribute it and/or modify
0024 % it under the terms of the GNU General Public License as published by
0025 % the Free Software Foundation, either version 3 of the License, or
0026 % (at your option) any later version.
0027 %
0028 % Dynare is distributed in the hope that it will be useful,
0029 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0030 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0031 % GNU General Public License for more details.
0032 %
0033 % You should have received a copy of the GNU General Public License
0034 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0035 
0036 if strcmpi(type,'posterior')
0037     posterior = 1;
0038     if nargin==4
0039         var_list_ = options_.varobs;
0040     end
0041 elseif strcmpi(type,'prior')
0042     posterior = 0;
0043     if nargin==4
0044         var_list_ = options_.prior_analysis_endo_var_list;
0045         if isempty(var_list_)
0046             options_.prior_analysis_var_list = options_.varobs;
0047         end
0048     end
0049 else
0050     disp('compute_moments_varendo:: Unknown type!')
0051     error()
0052 end
0053 
0054 NumberOfEndogenousVariables = rows(var_list_);
0055 NumberOfExogenousVariables = M_.exo_nbr;
0056 list_of_exogenous_variables = M_.exo_names;
0057 NumberOfLags = options_.ar;
0058 if isfield(options_,'conditional_variance_decomposition')
0059     Steps = options_.conditional_variance_decomposition;
0060 else
0061     Steps = 0;
0062 end
0063 
0064 % COVARIANCE MATRIX.
0065 if posterior
0066     for i=1:NumberOfEndogenousVariables
0067         for j=i:NumberOfEndogenousVariables
0068             oo_ = posterior_analysis('variance',var_list_(i,:),var_list_(j,:),[],options_,M_,oo_);
0069         end
0070     end
0071 else
0072     for i=1:NumberOfEndogenousVariables
0073         for j=i:NumberOfEndogenousVariables
0074             oo_ = prior_analysis('variance',var_list_(i,:),var_list_(j,:),[],options_,M_,oo_);
0075         end
0076     end
0077 end
0078 % CORRELATION FUNCTION.
0079 if posterior
0080     for h=NumberOfLags:-1:1
0081         for i=1:NumberOfEndogenousVariables
0082             for j=1:NumberOfEndogenousVariables
0083                 oo_ = posterior_analysis('correlation',var_list_(i,:),var_list_(j,:),h,options_,M_,oo_);
0084             end
0085         end
0086     end
0087 else
0088     for h=NumberOfLags:-1:1
0089         for i=1:NumberOfEndogenousVariables
0090             for j=1:NumberOfEndogenousVariables
0091                 oo_ = prior_analysis('correlation',var_list_(i,:),var_list_(j,:),h,options_,M_,oo_);
0092             end
0093         end
0094     end
0095 end
0096 % VARIANCE DECOMPOSITION.
0097 if M_.exo_nbr > 1
0098     if posterior
0099         for i=1:NumberOfEndogenousVariables
0100             for j=1:NumberOfExogenousVariables
0101                 oo_ = posterior_analysis('decomposition',var_list_(i,:),M_.exo_names(j,:),[],options_,M_,oo_);
0102             end
0103         end
0104     else
0105         for i=1:NumberOfEndogenousVariables
0106             for j=1:NumberOfExogenousVariables
0107                 oo_ = prior_analysis('decomposition',var_list_(i,:),M_.exo_names(j,:),[],options_,M_,oo_);
0108             end
0109         end        
0110     end
0111     % CONDITIONAL VARIANCE DECOMPOSITION.
0112     if Steps
0113         if posterior
0114             for i=1:NumberOfEndogenousVariables
0115                 for j=1:NumberOfExogenousVariables
0116                     oo_ = posterior_analysis('conditional decomposition',i,M_.exo_names(j,:),Steps,options_,M_,oo_);
0117                 end
0118             end
0119         else
0120             for i=1:NumberOfEndogenousVariables
0121                 for j=1:NumberOfExogenousVariables
0122                     oo_ = prior_analysis('conditional decomposition',var_list_(i,:),M_.exo_names(j,:),Steps,options_,M_,oo_);
0123                 end
0124             end
0125         end
0126     end
0127 end

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005