Should we use posterior mean or posterior mode

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.

Should we use posterior mean or posterior mode

Postby bigbigben » Wed Sep 07, 2011 12:39 am

I estimate some medium DSGE models and find the posterior mode does not coincide with the posterior mean. Is it common in Bayesian estimation? If not, how should I improve the model? If yes, I am not sure which set of parameter values I should use for further quantitative exercise, because they tell me different things about the estimated model. Some important moment conditions are quite different from simulations based on the two sets of numbers. Which one is more trustworthy?
bigbigben
 
Posts: 171
Joined: Sun May 28, 2006 1:19 am

Re: Should we use posterior mean or posterior mode

Postby jpfeifer » Wed Sep 07, 2011 12:39 pm

Hi, the mean and the mode of the posterior distribution are just two measures of the central tendency of the distribution. If the posterior distribution of a parameter is normal, the mean, the mode and the median will be the same. However, typically the exact distribution of the posterior is not known. In this case you have to pick a measure. Usually with irregular posteriors I would go with the mode. To see the problem consider a binomially distributed posterior with p=0.6. In this case, 60% of the draws will be 1 and 40% will be 0. The mode will be 1 and the mean will be 0.6. I would argue that the mode represents the distribution better than the mean (particularly as the latter is not guaranteed to fall on a value actually obtained in the sample).
However, I am sure you can construct cases where the mean is a better measure. I would recommend plotting the posterior distribution and see where the mean and the mode are for the parameters and then choose the one that better represents the sample.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Should we use posterior mean or posterior mode

Postby bigbigben » Wed Sep 07, 2011 12:49 pm

Thanks. The explanation is very clear. Your answer to my other questions are very appreciated as well.
bigbigben
 
Posts: 171
Joined: Sun May 28, 2006 1:19 am

Re: Should we use posterior mean or posterior mode

Postby bigbigben » Thu Sep 08, 2011 1:48 pm

Thanks for the answers. Here is a follow up question. By default, the simulation after the estimation command is at the posterior mode. What if I want to use the posterior mean? I guess that I have to write another dynare code. However, I have trouble to specify the shock deviations, because the keyword 'stderr' cannot be followed by variable names Here is what I do:

I just write a code identical to the estimation code except the parameter values are undetermined. In the code, I read the value from posterior_mean by writing
The estimation code is named as ABC

load ABC_mode.mat;
load ABC_results.mat;

estim_param=char(parameter_names); %get the string variable containg the name of estimated parameters, if I have multiple parameters estimated, I need to write a loop.

n_num=size(estim_param,1);
for iter=1:n_num;
val([estim_param(iter,:) '= oo_.posterior_mean.parameters.'estim_param(iter,:)]);
end;

This works fine for parameters other than the standard deviations for shocks. Assume I need to pick the std for shock1, I wrote

shocks;
var shock1;stderr oo_.posterior_mean.shocks_std.shock1;
end;

Dynare will give the error message:

character unrecognized by lexer

How should I deal with it?

Thank you for the attention.
bigbigben
 
Posts: 171
Joined: Sun May 28, 2006 1:19 am

Re: Should we use posterior mean or posterior mode

Postby jpfeifer » Sat Sep 10, 2011 7:12 am

You could specify your shock processes as
Code: Select all
x=rho*x(-1)+sigma_e*epsilon;

where sigma_e is an estimated parameter and
Code: Select all
shocks;
var epsilon; stderr = 1;
end

Thereby the estimated standard deviation sigma_e is now a normal parameter and you can use the procedure described.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Should we use posterior mean or posterior mode

Postby bigbigben » Sat Sep 10, 2011 1:59 pm

Thanks. However, I cannot do the same thing to the estimation code, can I? I mean I just fix the standard deviation of shock to 1 but iterate the size of the multipliers in front of it.

Attached is a simple attempt of mine, and dynare gives me the error message:

??? Error using ==> kalman_filter at 83
The variance of the forecast error remains singular until the end of the sample

The file xydata.mat is generated in the following way:

x=3*randn(100,1);
y=.9*x+randn(100,1);
save xydata x y;
Attachments
estxy.mod
(527 Bytes) Downloaded 198 times
bigbigben
 
Posts: 171
Joined: Sun May 28, 2006 1:19 am

Re: Should we use posterior mean or posterior mode

Postby jpfeifer » Sun Sep 11, 2011 8:28 am

Hi, from my experience, this one should work. I think you are just missing the shocks-block that standardizes the variance to 1. If I add it, I get exactly the same results as with the standard estimation approach. See the attached files
Attachments
estxy2.mod
Standard Estimation
(601 Bytes) Downloaded 266 times
estxy.mod
Estimation with parameter as prefactor
(595 Bytes) Downloaded 232 times
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Should we use posterior mean or posterior mode

Postby bigbigben » Sun Sep 11, 2011 9:31 am

Thanks! That really helps.
bigbigben
 
Posts: 171
Joined: Sun May 28, 2006 1:19 am

Re: Should we use posterior mean or posterior mode

Postby bigbigben » Mon Sep 12, 2011 4:19 am

Thanks for all the help with my question on this topic, however, I find the simulation after estimation is still a mystery. I am not sure what parameter values are used by dynare. The simulation outcome right after estimation is far from the results simulated based on posterior mean, or posterior mode or even the mode before the MH step.

I hereby upload an example with real data.

tryhard_est5.mod estimates the model, simulates a sample and computes certain moments.

tryhard_cal5_mean uses the posterior mean to simulate and compute the same moments.


tryhard_cal5_mode uses the posterior mode to simulate and compute the same moments.


tryhard_cal5_premh uses the posterior mode before the MH step to simulate and compute the same moments.

tryhard_cal_mean and tryhard_cal_mode load the results from tryhard_est5.mod automatically, but tryhard_cal5_premh use the pre-MH mode(mean?) by manually copying and pasting.

What I find it is that the results baed on posterior mean, mode and mode before MH are quite similar, but the result right after estimation is not. What causes the difference? Do dynare use a different set of parameter values but we don't know what it is.
Attachments
tryhard5.zip
(59.94 KiB) Downloaded 193 times
bigbigben
 
Posts: 171
Joined: Sun May 28, 2006 1:19 am

Re: Should we use posterior mean or posterior mode

Postby Oriana » Sat Aug 29, 2015 9:59 am

Hi,

I am running a rather complex model that has already provided the results below. Nevertheless, I have some concerns about the adequacy of priors and posteriors distributions. The convergence diagnostic also points that the chains have not converged.

Additionally Dynare posted the following warning:
Warning: Matrix is singular to working precision.
> In missing_DiffuseKalmanSmootherH1_Z at 249
In DsgeSmoother at 197
In evaluate_smoother at 90
In shock_decomposition at 60
In nonlinearomega at 2283
In dynare at 180

In contrast the acceptance ratio and the identification analysis seems quite good.
I am looking to know if the overall results are acceptable or, on the contrary, if it sounds that the model has some kind of misspecification related to prior distribution, etc...
I should be most thankful to an experienced advice on this matter.
Attachments
Shock decomposition.zip
(98.94 KiB) Downloaded 93 times
nonlinear_JP_29 August Bodeinstein 1 copy.0059 7.zip
(634.62 KiB) Downloaded 78 times
PriorsAndPosteriors.zip
(163.88 KiB) Downloaded 104 times
convergence diagonostic .zip
(234.06 KiB) Downloaded 97 times
IRF.zip
(260.51 KiB) Downloaded 65 times
Oriana
 
Posts: 67
Joined: Fri Jul 18, 2014 2:49 pm

Re: Should we use posterior mean or posterior mode

Postby jpfeifer » Sun Aug 30, 2015 2:34 pm

Your posterior does not look good at all. Non-convergence seems to be a big issue. Definitely use a longer chain and have a look at the trace_plots to see how the MCMC behaves.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Should we use posterior mean or posterior mode

Postby Oriana » Wed Sep 02, 2015 9:57 am

Dear Pfeifer,
I am very thankful for your previous advice. I already increased the chain to 50000 draws, however, I didn't reach convergence . The convergence diagnostics plots are posted below.
Unfortunately, I clumsy overwrite the trace plots. Nevertheless, it also showed that only very few parameters had converged.
Should the chain must be longer or there is probably some misspecification issue with my model?

In matter of fact I must inform you that, initially, it was very hard to find the posterior mode . With only very few parameters to estimate I simple got the error: Error using chol - The matrix must be positive definite.

Therefore following your previous advice (viewtopic.php?f=1&t=4841&start=15) although you didn't always recommended it I replaced the line [b]chol(hh) in the try-catch-statement of dynare_estimation_1.m by hh=1e-4*eye(size(hh)). [/b]

Today, I have tried to remake the calculation with the original code of dynare_estimation_1.m. I found that it is not out of question that some kind of model misspecification is related to the match between my model and observable variables namely, gov_share_jp_obs, oilprod_jp_deltalog_obs, oilprod_for_deltalog_obs, oilprod_jp_deltalog_obs_quarterly.

Futhermore, with the original code of dynare_estimation_1.m, the output from compute_mode = 9 is the following
POSTERIOR KERNEL OPTIMIZATION PROBLEM!
(minus) the hessian matrix at the "mode" is not positive definite!
=> posterior variance of the estimated parameters are not positive.
You should try to change the initial values of the parameters using
the estimated_params_init block, or use another optimization routine.

If you have some time to give me a better insight on this matter I shall be extremely obliged to you.
Attachments
nonlinear_JP_31 August Bodeinstein 1 copy.0059 long chain copy 5.zip
(641.08 KiB) Downloaded 81 times
Oriana
 
Posts: 67
Joined: Fri Jul 18, 2014 2:49 pm

Re: Should we use posterior mean or posterior mode

Postby Oriana » Thu Sep 03, 2015 7:55 pm

Due to the previous post, below are the trace plots and additional results for 100000 draws (with small identity matrix code).
After a full check up on the model I got approximately the same results with the standard dynare code and after to set it to a small identity matrix.
However, estimate all parameters with the standard dynare code proved once again almost impossible (the console output is in nonlinearomega consola output .txt in the shock decompositions & Priors.zip folder). How trustful are these results?

About the concerns expressed for the posteriors I may observe that all priors mean are the optimal values (estimated by the model's author with the maximum likelihood method), what may explain the vertical line of the posteriors, the convergence diagnostics and the trace plot of all parameters.
If so, should I change the mean of the priors to different, but near, values?
Any suggestion shall be welcome!
Attachments
shock decompositions & Priors.zip
(636.51 KiB) Downloaded 90 times
IRF_udiag.zip
(529.75 KiB) Downloaded 83 times
trace_plots 3.zip
(1.02 MiB) Downloaded 74 times
trace_plots2.zip
(812.29 KiB) Downloaded 67 times
trace_plots1.zip
(757.07 KiB) Downloaded 67 times
Oriana
 
Posts: 67
Joined: Fri Jul 18, 2014 2:49 pm

Re: Should we use posterior mean or posterior mode

Postby Oriana » Fri Sep 04, 2015 7:24 am

Added to the previous post.
Attachments
nonlinear_USA_3 Sep_ 100000 draws_Code Bodenstein 1970 copy.zip
(328.69 KiB) Downloaded 66 times
Oriana
 
Posts: 67
Joined: Fri Jul 18, 2014 2:49 pm

Re: Should we use posterior mean or posterior mode

Postby Oriana » Sat Sep 05, 2015 9:23 am

I look forward to some feedback, please!
Oriana
 
Posts: 67
Joined: Fri Jul 18, 2014 2:49 pm

Next

Return to Dynare help

Who is online

Users browsing this forum: No registered users and 1 guest

cron