Finish implementation of truncated normal distribution

Closes https://git.dynare.org/Dynare/dynare/-/issues/1593
kalman-mex
Johannes Pfeifer 2023-09-06 12:46:41 +02:00
parent 16f921ed62
commit d60a19ce49
4 changed files with 11 additions and 10 deletions

View File

@ -5912,13 +5912,14 @@ observed variables.
.. option:: PRIOR_3RD_PARAMETER .. option:: PRIOR_3RD_PARAMETER
A third parameter of the prior used for generalized beta A third parameter of the prior used for generalized beta
distribution, generalized gamma, generalized Weibull and for distribution, generalized gamma, generalized Weibull, the truncated normal, and for
the uniform distribution. Default: ``0``. the uniform distribution. Default: ``-Inf`` for normal distribution, ``0`` otherwise.
.. option:: PRIOR_4TH_PARAMETER .. option:: PRIOR_4TH_PARAMETER
A fourth parameter of the prior used for generalized beta A fourth parameter of the prior used for generalized beta
distribution and for the uniform distribution. Default: ``1``. distribution, the truncated normal, and for the uniform distribution.
Default: ``Inf`` for normal distribution, ``1`` otherwise.
.. option:: SCALE_PARAMETER .. option:: SCALE_PARAMETER

View File

@ -54,8 +54,8 @@ switch pshape(indx)
abscissa = linspace(infbound,supbound,steps); abscissa = linspace(infbound,supbound,steps);
dens = density(abscissa,p6(indx),p7(indx),p3(indx)); dens = density(abscissa,p6(indx),p7(indx),p3(indx));
case 3% Gaussian prior case 3% Gaussian prior
infbound = norminv(truncprior,p6(indx),p7(indx)); infbound = max(p3(indx),norminv(truncprior,p6(indx),p7(indx)));
supbound = norminv(1-truncprior,p6(indx),p7(indx)); supbound = min(p4(indx),norminv(1-truncprior,p6(indx),p7(indx)));
abscissa = linspace(infbound,supbound,steps); abscissa = linspace(infbound,supbound,steps);
dens = normpdf(abscissa,p6(indx),p7(indx)); dens = normpdf(abscissa,p6(indx),p7(indx));
case 4% Inverse-gamma of type 1 prior case 4% Inverse-gamma of type 1 prior

View File

@ -93,11 +93,11 @@ for i=1:length(p6)
end end
case 3 case 3
if prior_trunc == 0 if prior_trunc == 0
bounds.lb(i) = -Inf; bounds.lb(i) = max(-Inf,p3(i));
bounds.ub(i) = Inf; bounds.ub(i) = min(Inf,p4(i));
else else
bounds.lb(i) = norminv(prior_trunc,p6(i),p7(i)); bounds.lb(i) = max(norminv(prior_trunc,p6(i),p7(i)),p3(i));
bounds.ub(i) = norminv(1-prior_trunc,p6(i),p7(i)); bounds.ub(i) = min(norminv(1-prior_trunc,p6(i),p7(i)),p4(i));
end end
case 4 case 4
if prior_trunc == 0 if prior_trunc == 0

View File

@ -70,7 +70,7 @@ estimated_params;
alp, beta_pdf, 0.356, 0.02; alp, beta_pdf, 0.356, 0.02;
bet, beta_pdf, 0.993, 0.002; bet, beta_pdf, 0.993, 0.002;
gam, normal_pdf, 0.0085, 0.003; gam, normal_pdf, 0.0085, 0.003;
mst, normal_pdf, 1.0002, 0.007; mst, normal_pdf, 1.0002, 0.007,1.0002-3*0.007,1.0002+3*0.007;
rho, beta_pdf, 0.129, 0.223; rho, beta_pdf, 0.129, 0.223;
psi, beta_pdf, 0.65, 0.05; psi, beta_pdf, 0.65, 0.05;
del, beta_pdf, 0.01, 0.005; del, beta_pdf, 0.01, 0.005;