Bug in the function PosteriorIRF.m


I found a bug in the PosteriorIRF.m function. Look at the code for compution the IRFs to orthogonalized shocks.

SS(M_.exo_names_orig_ord,M_.exo_names_orig_ord) = M_.Sigma_e+1e-14*eye(M_.exo_nbr);
    SS = transpose(chol(SS));
    for i = 1:M_.exo_nbr
        if SS(i,i) > 1e-13
            y=irf(dr,SS(M_.exo_names_orig_ord,i), options_.irf, options_.drop,options_.replic,options_.order);
            if options_.relative_irf
                y = 100*y/cs(i,i);
            for j = 1:nvar
                if max(y(IndxVariables(j),:)) - min(y(IndxVariables(j),:)) > 1e-12 
                    stock_irf_dsge(:,j,i,irun) = transpose(y(IndxVariables(j),:));

There should be cs = transpose(chol(SS)); and SS should be replaced by cs after this command, so that the code will be the same as in the function stoch_simul.m.

Two more suggestions. The control condition

** if SS(i,i) > 1e-13**

should be replaced by

** if cs(i,i) > sqrt(1e-13)**

The reason is that e.g. let SS = [1 1;1 1]. Then** cs = [1 0; 1 0]**, so that there is only one orthogonal shock. More generally the number of orthogonal shock is equal to the rank of the matrix SS, but not to the number of nonzero elements on the diagonal of SS.

Another issue is how to choose the right normalization for relative shock. I think that

** y = 100*y/cs(i,i);**

should better be replaced by

** y = 100*y/sum(cs(:,i));**