IRIS-Solutions-Team / IRIS-Toolbox

[IrisToolbox] for Macroeconomic Modeling
Other
92 stars 42 forks source link

PosterStd os Bayesian Estimation #331

Open JoaoHaddad opened 2 years ago

JoaoHaddad commented 2 years ago

Hi, a possible silly question:

Why does the function estimate generates some parameter's PosterStd equal to 4?

image

jaromir-benes commented 2 years ago

Hi - this occurs whenever there's a numeric problem when evaluating the hessian in the neighborhood of the mode for that particular parameter. In that case, the diagonal element of the inversed Hessian is replaced with 4*max(x, 1) where x is the mode of the parameter.

Hard to say what could have caused the numeric problems here - could you possibly upload everything needed to reproduce your results, and look into the issue?

Best Jaromir

On Wed, Jul 20, 2022 at 4:21 AM JoaoHaddad @.***> wrote:

Hi, a possible silly question:

Why does the function estimate generates some parameter's PosterStd equal to 4?

[image: image] https://user-images.githubusercontent.com/109638844/179882055-8093ce85-b4f1-46a6-aaa3-fde4731725eb.png

— Reply to this email directly, view it on GitHub https://github.com/IRIS-Solutions-Team/IRIS-Toolbox/issues/331, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGCVKKWXF3XISNYUKWRQCMLVU5PDTANCNFSM54B56F5A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jaromir-benes commented 2 years ago

Hi

The std reported should be, in theory, based on the inverse of the Hessian (i.e. the matrix of second derivatives of the posterior density w.r.t to parameters) at the optimum. However, because the Hessian returned from the Optimization Tbx has usually all sorts of numeric problems (because it's a very crude approximation based mostly on consecutive updates from Jacobians only, i.e. first derivatives) and is rarely invertible, we instead compute partial second derivatives (individually for each parameter, keeping the other parameters fixed) in IrisT as a crude measure of the parameter estimate variability.

Here, sometimes, the second derivative has a negative sign - a situation occurring when there is a strong cross-correlation between the estimates of individual parameters. In that case, a placeholder value of 4*max(x, 1) is inserted instead.

Also a couple of observations:

For instance, do

f = distribution.Beta.fromMeanStd(0.05,0.005); x = 0.05 : 0.001 : 0.95; figure(); plot(x, f.logPdf(x));

Mostly, the normal distribution (which implies a quadratic shape in terms of its log density) combined with lower and upper bounds (=truncation) is the best option to translate our priors to numerical representation.

Best Jaromir

On Wed, Jul 20, 2022 at 4:33 PM JoaoHaddad @.***> wrote:

Modelo.zip https://github.com/IRIS-Solutions-Team/IRIS-Toolbox/files/9150767/Modelo.zip

Hi Jaromir,

There it is.

Thanks for the answer, João

— Reply to this email directly, view it on GitHub https://github.com/IRIS-Solutions-Team/IRIS-Toolbox/issues/331#issuecomment-1190364877, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGCVKKUKCQPVGXLGBCZMVATVVAE4FANCNFSM54B56F5A . You are receiving this because you commented.Message ID: @.***>