Page 1 of 1

Bug in the function PosteriorIRF.m

PostPosted: Sat Nov 28, 2009 10:29 am
by pakocica
Hi,

I found a bug in the PosteriorIRF.m function. Look at the code for compution the IRFs to orthogonalized shocks.
Code: Select all
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);
            end
            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),:));
                end
            end
        end
    end


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.

Re: Bug in the function PosteriorIRF.m

PostPosted: Tue Dec 01, 2009 2:30 am
by pakocica
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));

Regards,

Pavel