Page 1 of 1

Variance of endogenous variables in OSR

PostPosted: Tue Mar 11, 2014 12:01 am
by VAL
In OSR computations, the variance-covariance matrix of endogenous variables appears to be different from the one reported by stoch_simul (order=1).

In OSR, the variance-covariance matrix is computed by the following code (last line of get_variance_of_endogenous_variables.m)
Code: Select all
vx1(i_stat,i_stat) = ghx(:,i_stat_0)*vx(i_stat_0,i_stat_0)*ghx(:,i_stat_0)'+ghu*Sigma_e*ghu';
while in stoch_simul, the matrix is computed as in line 143 of th_autocovariances.m
Code: Select all
v(stationary_vars,stationary_vars) = aa*vx*aa'+ bb*M_.Sigma_e*bb';

The difference between the two expressions is in the first term. While in stoch_simul the entire vx matrix is employed, in OSR only a sub matrix of vx identified by i_stat_0 indices is used. Numerically, the difference in terms of the value of the loss function (specified in OSR) is noticeable (20% for my model). Is there really a need for the two computations of the same matrix to be different?

Re: Variance of endogenous variables in OSR

PostPosted: Tue Mar 11, 2014 9:06 am
by jpfeifer
I don't get the point. In OSR, only the variance for variables in the loss function are selected. But the big covariance matrices from which the entries are selected are identical.

Re: Variance of endogenous variables in OSR

PostPosted: Tue Mar 11, 2014 4:10 pm
by VAL
It is true that in OSR (in the line of code cited above) the variance-covariance matrix is computed only for the variables specified in the loss function. For example, if there are 3 variables in the loss function, the matrix is [3x3]. When running stoch_simul, I compute statistics for exactly the same variables. As a shortcut, the statistics can be also obtained by disp_th_moments(oo_.dr,['x1';'x2';'x3']).

The difference between the computations in osr and in stoch_simul lies in the computation of the first term in the two lines of code above. In OSR/get_variance_of_endogenous_variables because of i_stat_0 the dimension of matrices in the expression ghx(:,i_stat_0)*vx(i_stat_0,i_stat_0)*ghx(:,i_stat_0)' could be, for example, [3x50]x[50x50]x[50x3]. In stoch_simul/disp_th_moments the dimension of matrices in aa*vx*aa' could be [3x120]x[120x120]x[120x3]. In both cases, the resulting variance-covariance matrices are [3x3], but the matrices are not the same.

The issue seems to boil down to imposing abs(A*u)<options_.Schur_vec_tol in line 51 of get_variance_of_endogenous_variables.m (in addition to abs(ghx*u)<options_.Schur_vec_tol) and not imposing the restriction in th_autocovariances.m.

Re: Variance of endogenous variables in OSR

PostPosted: Tue Mar 11, 2014 9:32 pm
by jpfeifer
I see. According to my understanding, this should only matter for unit root variables. Could you provide me with an example mod-file where the problem occurs?