european-central-bank / BEAR-toolbox

The Bayesian Estimation, Analysis and Regression toolbox (BEAR) is a comprehensive (Bayesian Panel) VAR toolbox for forecasting and policy analysis.
98 stars 38 forks source link

IRF Output in Excel displays wrong values in some cases #50

Open jpfahls opened 1 year ago

jpfahls commented 1 year ago

The Excel Sheet "IRF" displays the wrong values for the impulse response function in case of a structural identification scheme (IRFt==4 in my case) if the shock labels do not start for the first series (column c in the first screenshot). Screenshot 2 shows the computed IRF in Matlab and screenshot 3 the excel output. I reckon the error occurs in a loop the function excelrecord4fcn.m.

for ii=1:n tempcell={}; % loop over shocks (horizontal dimension) for jj=1:identified % create cell of IRF record for variable ii in response to shock jj % if a sign restriction identification scheme has been used, use the structural shock labels if IRFt==4||IRFt==5||IRFt==6 temp=['response of ' endo{ii,1} ' to ' strctident.signreslabels_shocks{jj,1} ' shocks']; else temp=['response of ' endo{ii,1} ' to ' endo{jj,1} ' shocks']; end irf_ij=[temp {''} {''} {''};{''} {''} {''} {''};{''} {'lw. bound'} {'median'} {'up. bound'};num2cell((1:IRFperiods)') num2cell((irf_estimates{ii,jj})')]; tempcell=[tempcell irf_ij vertspace]; end

jj=1:identified equals 1:1 in my case since the variable identified is identified=size(strctident.signreslabels_shocks,1) which is just one label in my case. So irf_ij computes the first coloum of irf_estimates( nxn matrix with n=number of endogenous variable=5 in my case) although in my case the third column contains the right IRFs. Screeshot four and five show IRF_estimates 1,1 and 1,3. Hence, Excel output is only correct if the first x shocks are specified and named in the data sheet.
Screenshot_5_IRF_estimates_1_3 Screenshot_4_irf_estimates_1_1 Screenshot_3_excel_output Screenshot_2_Matlab_output Screenshot_1_Labels