Bug in the function PosteriorIRF.m

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Bug in the function PosteriorIRF.m

Postby pakocica » Sat Nov 28, 2009 10:29 am

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.
pakocica
 
Posts: 46
Joined: Fri Nov 27, 2009 6:42 pm
Location: Taiwan (come from Prague)

Re: Bug in the function PosteriorIRF.m

Postby pakocica » Tue Dec 01, 2009 2:30 am

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
pakocica
 
Posts: 46
Joined: Fri Nov 27, 2009 6:42 pm
Location: Taiwan (come from Prague)


Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 10 guests