Posterior predictive moments

Hi,

I would like to generate and compare the posterior predictive moments of variables (covariances, autocorrelations etc) yielded by the estimation exercise to the corresponding ones in the data. I found this post from the past, but it seems to have a few critical lines erased (for example, the line before and after “…command and within the posterior function call…”)
Posterior predictive checks.

Any help (new or old, in terms of recovering the above post in its entirety) would be much appreciated. Thanks a lot in advance.

Nikhil

I fixed the post you referenced. You might also want to check out

Hi Johannes,

Thanks a lot for your help. I was able to run the file based on the routine which uses “posterior_function_demo.m” file, but I am having trouble understanding some of the output. The “oo_.posterior_function_results” is a 500 by 2 cell, where 500 = number of sampling draws.

size(oo_.posterior_function_results{x,1}) = [9 1] for 0<x<=500, where 9 = number of variables that i specified in the var_list in the posterior_function_demo file. I believe this corresponds to the mean of the 9 variables for the xth sample draw, since i have specified “output_cell{1,1}=oo_.mean" in the “posterior_function_demo.m” file.

when i specify “output_cell{1,1}=oo_.var”, size(oo_.posterior_function_results{x,1}) = [9 9], I suppose this is the variance covariance matrix, with diagonal elements denoting variances. Am i correct that i can average across the x dimension (=500) to get a measure of the “mean” variances and covariances? is there an easy command to compute autocovariances in a similar way (perhaps this is where I need to use the second file that you referenced, but I am not sure how)?

Also, size(oo_.posterior_function_results{x,2}) = [200 60]; I do not understand the contents of this cell suppose 200 stands for the sample size (i specified “options_.drop=100” and “options_.periods=200”. what does the second dimension “60” represent?

Regards

posterior_function_demo1.m (3.3 KB)
mar11c2_new2_feb2019_ppm.mod (19.8 KB)
mar11c2_new2_feb2019_ppm_mode.mat (10.0 KB)

  1. You are correct on your conjectures.
  2. The covariances will be in oo_.gamma_y (see the manual).
  3. Your second output is the simulation output ys. It is M_.endo_nbr=60 times options_.periods=200

Thanks a lot. For 2, I do not get the “oo_.gamma_y” variable at the end of the estimation routine as it stands. Should I run a stochastic simulation after the estimation command, something like


estimation (…)
posterior_function(function=‘posterior_function_demo1’, sampling_draws=500);

% read out the contents of the cell and put them into ndraws by ncolumns
posterior_params=cell2mat(oo_.posterior_function_results(:,1));
posterior_steady_states=cell2mat(oo_.posterior_function_results(:,2));

prior_function(function=‘posterior_function_demo1’);

% read out the contents of the cell and put them into ndraws by ncolumns
prior_params=cell2mat(oo_.prior_function_results(:,1));
prior_steady_states=cell2mat(oo_.prior_function_results(:,2));

stoch_simul(irf=60) PI PI_star;

Alternatively, can I use the {oo_.posterior_function_results{x,2}) dimension, which you clarified is the simulation output, to compute the autocovariances myself “by hand”?

You need to modify posterior_function_demo1 to provide this as an output.

Thanks a lot for the response. I have tried to modify the file in various ways but unfortunately none of them seem to work. In partcular, I cannot get the simult function to give out the oo_.gamma_y output (like in the case of stoch_simul)

Also, I wonder if the second part of my previous post makes sense, or is that not an appropriate way to compute the moments?

“Alternatively, can I use the {oo_.posterior_function_results{x,2}) dimension, which you clarified is the simulation output, to compute the autocovariances myself “by hand”?”

The issue is that you are currently requesting simulated moments, but gamma_y stores theoretical moments.