Home > matlab > get_variance_of_endogenous_variables.m

get_variance_of_endogenous_variables

PURPOSE ^

function vx1 = get_variance_of_endogenous_variables(dr,i_var)

SYNOPSIS ^

function vx1 = get_variance_of_endogenous_variables(dr,i_var)

DESCRIPTION ^

 function vx1 = get_variance_of_endogenous_variables(dr,i_var)
 Gets the variance of a variables subset

 INPUTS
    dr:        structure of decisions rules for stochastic simulations
    i_var:     indices of a variables list
        
 OUTPUTS
    vx1:       variance-covariance matrix
        
 SPECIAL REQUIREMENTS
    none

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function vx1 = get_variance_of_endogenous_variables(dr,i_var)
0002 
0003 % function vx1 = get_variance_of_endogenous_variables(dr,i_var)
0004 % Gets the variance of a variables subset
0005 %
0006 % INPUTS
0007 %    dr:        structure of decisions rules for stochastic simulations
0008 %    i_var:     indices of a variables list
0009 %
0010 % OUTPUTS
0011 %    vx1:       variance-covariance matrix
0012 %
0013 % SPECIAL REQUIREMENTS
0014 %    none
0015 
0016 % Copyright (C) 2003-2011 Dynare Team
0017 %
0018 % This file is part of Dynare.
0019 %
0020 % Dynare is free software: you can redistribute it and/or modify
0021 % it under the terms of the GNU General Public License as published by
0022 % the Free Software Foundation, either version 3 of the License, or
0023 % (at your option) any later version.
0024 %
0025 % Dynare is distributed in the hope that it will be useful,
0026 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0027 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0028 % GNU General Public License for more details.
0029 %
0030 % You should have received a copy of the GNU General Public License
0031 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0032 
0033 global M_ options_
0034 
0035 endo_nbr = M_.endo_nbr;
0036 
0037 Sigma_e = M_.Sigma_e;
0038 
0039 nstatic = dr.nstatic;
0040 npred = dr.npred;
0041 ghx = dr.ghx(i_var,:);
0042 ghu = dr.ghu(i_var,:);
0043 nc = size(ghx,2);
0044 n = length(i_var);
0045 
0046 [A,B] = kalman_transition_matrix(dr,nstatic+(1:npred),1:nc,M_.exo_nbr);
0047 
0048 [vx,u] = lyapunov_symm(A,B*Sigma_e*B',options_.qz_criterium,options_.lyapunov_complex_threshold);
0049 
0050 if size(u,2) > 0
0051     i_stat_0 = find(any(abs(A*u) < options_.Schur_vec_tol,2));
0052     i_stat = find(any(abs(ghx*u) < options_.Schur_vec_tol,2));
0053     
0054     ghx = ghx(i_stat,:);
0055     ghu = ghu(i_stat,:);
0056 else
0057     i_stat_0 = 1:size(ghx,2);
0058     i_stat = (1:n)';
0059 end
0060 
0061 vx1 = Inf*ones(n,n);
0062 vx1(i_stat,i_stat) = ghx(:,i_stat_0)*vx(i_stat_0,i_stat_0)*ghx(:,i_stat_0)'+ghu*Sigma_e*ghu';
0063

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