Bug in Gamma Prior?

Hi

I got the following results in the estimation of the NAWM-FIN (a large DSGE model for the euro area). The response of policy to inflation growth is negative despite the prior being a Gamma (highlighted in red below).

After having checked I realized that the Gamma distribution in Dynare returns non-zero values for negative values of the random variable i.e. lpdfgam(para(i)-p3(i),a,b).ne.0 for para(i)-p3(i)<0 (here p3(i)=0).

In particular it returns complex values (in the case at hand, mean=0.3, std=0.1, value=-0.2183. lpdfgam(para(i)-p3(i),a,b)= 14.3776 +25.1327i). This, somehow, does not trigger penalties or crashes.

This would badly distort the prior distribution (even if the mode happens to be in the positive region)!!

I’ll fix this on my installation of Dynare. Will you be fixing this in the general distribution?

Best

Gianni

RESULTS FROM POSTERIOR MAXIMIZATION
parameters
prior mean mode s.d. t-stat prior pstdev

 kappa_1   0.700   0.5883  0.0339 17.3348 beta  0.0500
   xi_W1   0.600   0.7749  0.0415 18.6703 beta  0.1000
  chi_W1   0.500   0.5998  0.0969  6.1879 beta  0.1000
    xi_H   0.600   0.9009  0.0128 70.5633 beta  0.1000
   chi_H   0.500   0.3905  0.0742  5.2588 beta  0.1000
    xi_X   0.600   0.7993  0.0411 19.4541 beta  0.1000
   chi_X   0.500   0.2901  0.0740  3.9181 beta  0.1000
   xi_IM   0.600   0.4671  0.0452 10.3241 beta  0.1000
  chi_IM   0.500   0.3863  0.0891  4.3340 beta  0.1000

omegastar 0.150 0.1462 0.0203 7.2121 beta 0.0500
mu_C 1.500 2.4049 0.3323 7.2368 gamm 0.2500
mu_I 1.500 1.8270 0.2838 6.4368 gamm 0.2500
mu_ast 1.500 1.1621 0.2078 5.5928 gamm 0.2500
gamma_I 4.000 4.2303 0.4815 8.7854 gamm 0.5000
gamma_IMC 2.500 2.7652 0.6791 4.0719 gamm 1.0000
gamma_IMI 2.500 1.6237 0.7574 2.1438 gamm 1.0000
gamma_ast 2.500 2.6896 0.6064 4.4352 gamm 1.0000
gamma_IH1 2.500 1.6180 0.3274 4.9418 gamm 1.0000
lambda_R 0.500 0.9856 0.0048 205.8334 beta 0.2000
lambda_pii 1.500 1.3795 0.1479 9.3246 gamm 0.4000
lambda_dpii 0.300 -0.2183 0.0545 4.0060 gamm 0.1000
lambda_dgdp 0.063 0.4463 0.0413 10.8149 gamm 0.0500
xiE 0.500 0.8904 0.0085 104.3937 beta 0.1500
rho_finance 0.750 0.7369 0.0521 14.1540 beta 0.0500
rho_RP 0.750 0.8647 0.0247 34.9464 beta 0.0500
rho_Gc 0.200 0.1384 0.0662 2.0891 beta 0.1000
rho_prod 0.750 0.8329 0.0232 35.8764 beta 0.0500
rho_I 0.750 0.7609 0.0460 16.5446 beta 0.0500
rho_w1 0.500 0.6451 0.0614 10.4989 beta 0.1000
rho_varphi_H 0.500 0.5162 0.0804 6.4195 beta 0.1000
rho_varphi_X 0.500 0.3473 0.0909 3.8201 beta 0.1000
rho_varphi_IM 0.500 0.5591 0.1039 5.3812 beta 0.1000
rho_IM 0.750 0.7710 0.0403 19.1210 beta 0.0500
rho_nu_ast 0.750 0.7702 0.0428 17.9820 beta 0.0500
std_finance 0.169 1.7442 0.1884 9.2583 invg 0.1279
std_RP 0.169 0.5456 0.0896 6.0915 invg 0.1279
std_Gc 0.169 0.4753 0.0437 10.8864 invg 0.1279
std_prod 0.169 2.2937 0.3097 7.4053 invg 0.1279
std_I 0.169 2.6956 0.3657 7.3721 invg 0.1279
std_w1 0.169 0.5914 0.0746 7.9231 invg 0.1279
std_varphi_H 0.169 0.3025 0.0263 11.4953 invg 0.1279
std_varphi_X 0.169 1.6360 0.1525 10.7297 invg 0.1279
std_varphi_IM 0.169 0.9099 0.1575 5.7769 invg 0.1279
std_IM 0.169 5.7778 0.8984 6.4309 invg 0.1279
std_nu_ast 0.169 9.0237 2.1618 4.1742 invg 0.1279
std_policy 0.169 0.0838 0.0184 4.5578 invg 0.1279
chi_2 0.050 0.0095 0.0014 6.7646 beta 0.0100
rho_chi 0.750 0.8549 0.0264 32.3357 beta 0.0500
rho_gamma 0.750 0.5289 0.0423 12.5164 beta 0.0500
rho_Gqh 0.200 0.2660 0.0784 3.3936 beta 0.1000
rho_RP_dom 0.750 0.9865 0.0032 312.5056 beta 0.0500
std_Gqh 0.169 1.0165 0.0798 12.7315 invg 0.1279
std_RP_dom 0.169 2.6292 0.3425 7.6766 invg 0.1279
std_chi 0.169 6.8033 1.0479 6.4924 invg 0.1279
std_gamma 0.169 0.7811 0.0598 13.0608 invg 0.1279

Log data density [Laplace approximation] is -2571.837212.

Hi Gianni,

I did not realize that our gamma density routine was able to evaluate the density for negative values of the variable… I will fix this. But the real problem is that the optimization routine should never go in this region… I guess that the problem must be with the definition of a penalty in DsgeLikelihood.m. Did you used the optimization algorithm 4 to get this result?

Best, Stéphane.

Hi Stephane,

The problem was a combination of typos/errors.

I mistakenly gave a negative lower bound for the parameter (I moved from a Gaussian to a Gamma and forgot to update the lower bound :blush: ) and Dynare did not warn me that negative values were accepted by the Gamma prior :cry: .

(btw: I used a combination of Bill Goff’s SA and option 4 (Sims’ code))

Best,

Gianni