Hello everyone,
Is there a way to compute confidence bands for variance decomposition in Dynare? Thanks.
Hello everyone,
Is there a way to compute confidence bands for variance decomposition in Dynare? Thanks.
Yes. The computation of the posterior distribution of the variance decomposition is triggered by the keyword moments_varendo in the estimation command. The results are saved in the oo_ global structure. For instance the Highest Probability Density interval containing eighty percent of the posterior distribution of the variance decomposition is given by:
oo_.PosteriorTheoreticalMoments.dsge.VarianceDecomposition.hpdinf.<NAME_OF_THE_ENDOGENOUS_VARIABLE>.<NAME_OF_THE_EXOGENOUS_VARIABLE>
and
oo_.PosteriorTheoreticalMoments.dsge.VarianceDecomposition.hpdsup.<NAME_OF_THE_ENDOGENOUS_VARIABLE>.<NAME_OF_THE_EXOGENOUS_VARIABLE>
The deciles of this posterior distribution can be found here:
oo_.PosteriorTheoreticalMoments.dsge.VarianceDecomposition.deciles.<NAME_OF_THE_ENDOGENOUS_VARIABLE>.<NAME_OF_THE_EXOGENOUS_VARIABLE>
Best,
Stéphane.
Hi Stephane,
Thanks a lot for your response, however I am facing some issues. When I try to trigger the computation of the posterior theoretical moments using “moments_varendo” in the estimation part I get an error message.
For example, when I run the following code:
estimation(datafile=XXX,first_obs=1,conf_sig=0.68, prefilter=1,mode_compute=5,mh_replic = 12000, mh_nblocks=2,irf=20, smoother,bayesian_irf, mode_check, mh_jscale=0.4,moments_varendo);
Then I get:
??? Too many outputs requested. Most likely cause is missing ] around
left hand side that has a comma separated list expansion.
Error in ==> get_date_of_a_file at 22
d1 = info.datenum;
Error in ==> check_posterior_analysis_data at 43
pddate = get_date_of_a_file( M_.dname ‘/metropolis/’ M_.fname
’_posterior_draws’…
Error in ==> posterior_analysis at 20
info = check_posterior_analysis_data(type,M_);
Error in ==> compute_moments_varendo at 41
oo_ =
posterior_analysis(‘variance’,var_list_(i,:),var_list_(j,:),],options_,M_,oo_);
Error in ==> dynare_estimation_1 at 959
oo_ = compute_moments_varendo(options_,M_,oo_,var_list_);
Error in ==> dynare_estimation at 62
dynare_estimation_1(var_list,varargin{:});
If I run the command above without “moments_varendo”, the code works just fine. Am I missing something? I would really appreciate your help.
Thanks a lot.
Stephane,
I have done the following. In get_date_of_a_file.m I wrote the following comand:
info=dir(filename);
if size(info, 1) == 0
error( filename ‘: non-existent file’ ]);
end
Then I get:
??? Error using ==> get_date_of_a_file at 23
testmodel/metropolis/testmodel_posterior_draws1.mat:
non-existent file
In the Metropolis subdirectory I can see testmodel_posterior_draws.mat, but not testmodel_posterior_draws1.mat. Is there a bug in Dynare? By the way, I am using the latest version of Dynare 4.04 and Matlab 7.7.
Hi, This is weird because since dynare 4.0.3 the posterior draws are saved in <MOD_FILE_NAME>_posterior_draws1.mat and not <MOD_FILE_NAME>_posterior_draws.mat as in your case. I wonder if you are not working with a file generated by an older version of dynare (at least 4.0.2). Can you remove your posterior draw file and try again?
Best,
Stéphane.
I figured it out. I had Dynare 4.02 in the Matlab path, although Dynare 4.04 was in the top of the path. Anyway, when I remove Dynare 4.02 from the path, then it works. However, two things seem interesting:
It takes a lot of time to get the results when moment_varendo is included in the estimation command (about 5x than the usual time, i.e., without moments_varendo).
I tested the model with 6 shocks, but only 4 shocks have confidence bands displayed in the structure oo_.PosteriorTheoreticalMoments… Weird!
By the way thanks for the help!
Dear all
When I specify moments_varendo in the estimation command i get the following error:
??? Reference to non-existent field ‘datenum’.
Error in ==> get_date_of_a_file at 22
d1 = info.datenum;
Error in ==> check_posterior_analysis_data at 31
mhdate = get_date_of_a_file(mhname);
Error in ==> posterior_analysis at 20
info = check_posterior_analysis_data(type,M_);
Error in ==> compute_moments_varendo at 41
oo_ = posterior_analysis(‘variance’,var_list_(i,:),var_list_(j,:),],options_,M_,oo_);
Error in ==> dynare_estimation_1 at 959
oo_ = compute_moments_varendo(options_,M_,oo_,var_list_);
Error in ==> dynare_estimation at 62
dynare_estimation_1(var_list,varargin{:});
Error in ==> usJRbenchmarkc at 528
dynare_estimation(var_list_);
Error in ==> dynare at 102
evalin(‘base’,fname) ;
Does anyone enountered this before. I am using 4.0.4.
Thanks
John
Hi John,
Check if some earlier version of Dynare appears in your Matlab path. Even if the lastest version is on the top of the path, Dynare gives an error if you have any previous version in the path.
Hope this can help.
Best
Hi Marcelo
Thanks for the tip. I have just changed ‘datenum’ to ‘date’ and it worked. I could not find any such field in dir. But i will try your suggestion as well.
Best
John
Hi Marcelo
I seem to get the same problem as you when I do the decomposition; I do not get the decomposition for all shocks for all variables I am interested in. Does this still persist for you?
Best
John
Hi John,
Unfortunately I still have the same problem. I haven’t tried to fix it yet, but I’ll let you know if I get anything.
Best,
Dear Marcelo and John,
Using my mod files I am not able to reproduce your problem (I get the confidance bands of the decomposition for all the shocks). Can you post a mod file?
Best,
Stéphane.
Hi,
under dynare, i am using the (moments_varendo) as follows:
estimation(datafile=data_eg1,nobs=79,mh_nblocks=5,prefilter=1,
mh_jscale=0.42,mh_replic=0,mode_file=ls2003_mode,mode_compute=0,
load_mh_file,mode_check,bayesian_irf,irf=12,moments_varendo );
but i get the following error:
Warning: Divide by zero. This warning will be removed in a future release.
Consider using DBSTOP IF NANINF when debugging.
In dsge_simulated_theoretical_conditional_variance_decomposition at 71
In posterior_analysis>job at 75
In posterior_analysis at 34
In compute_moments_varendo at 110
In dynare_estimation_1 at 1077
In dynare_estimation at 62
In ls2003 at 195
In dynare at 132
??? Subscripted assignment dimension mismatch.
Error in ==> conditional_variance_decomposition_mc_analysis at 70
p_mean(1, = Steps;
Error in ==> posterior_analysis>job at 78
oo_ =
conditional_variance_decomposition_mc_analysis(SampleSize,‘posterior’,M_.dname,M_.fname,…
Error in ==> posterior_analysis at 38
oo_ =
job(type,SampleSize,arg1,arg2,arg3,options_,M_,oo_,nvar,vartan);
Error in ==> compute_moments_varendo at 110
oo_ = posterior_analysis(‘conditional
decomposition’,var_list_(i,:),M_.exo_names(j,:),Steps,options_,M_,oo_);
Error in ==> dynare_estimation_1 at 1077
oo_ =
compute_moments_varendo(‘posterior’,options_,M_,oo_,var_list_);
Error in ==> dynare_estimation at 62
dynare_estimation_1(var_list,varargin{:});
Error in ==> ls2003 at 198
dynare_estimation(var_list_);
Error in ==> dynare at 132
evalin(‘base’,fname) ;
am i using the command of moments_varendo wrongly? and how can i solve this problem and get the confidence bands for variance decomposition.
Thanks for the help