method_of_moments: add warnings for problematic prior stderr/corr and value
Also moved oo_.prior to oo_.mom.priorkalman-mex
parent
017b4f05f6
commit
0cd65df72a
|
@ -263,12 +263,12 @@ oo_.mom.Q = residuals'*residuals;
|
|||
if options_mom_.mom.vector_output == 1 % lsqnonlin requires vector output
|
||||
fval = residuals;
|
||||
if options_mom_.mom.penalized_estimator
|
||||
fval=[fval;(xparam1-oo_.prior.mean)./sqrt(diag(oo_.prior.variance))];
|
||||
fval=[fval;(xparam1-oo_.mom.prior.mean)./sqrt(diag(oo_.mom.prior.variance))];
|
||||
end
|
||||
else
|
||||
fval = oo_.mom.Q;
|
||||
if options_mom_.mom.penalized_estimator
|
||||
fval=fval+(xparam1-oo_.prior.mean)'/oo_.prior.variance*(xparam1-oo_.prior.mean);
|
||||
fval=fval+(xparam1-oo_.mom.prior.mean)'/oo_.mom.prior.variance*(xparam1-oo_.mom.prior.mean);
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -283,14 +283,14 @@ if options_mom_.mom.compute_derivs && options_mom_.mom.analytic_jacobian
|
|||
|
||||
if options_mom_.mom.vector_output == 1 % lsqnonlin requires vector output
|
||||
if options_mom_.mom.penalized_estimator
|
||||
df(:,jp)=[dresiduals;dxparam1(:,jp)./sqrt(diag(oo_.prior.variance))];
|
||||
df(:,jp)=[dresiduals;dxparam1(:,jp)./sqrt(diag(oo_.mom.prior.variance))];
|
||||
else
|
||||
df(:,jp) = dresiduals;
|
||||
end
|
||||
else
|
||||
df(:,jp) = dresiduals'*residuals + residuals'*dresiduals;
|
||||
if options_mom_.mom.penalized_estimator
|
||||
df(:,jp)=df(:,jp)+(dxparam1(:,jp))'/oo_.prior.variance*(xparam1-oo_.prior.mean)+(xparam1-oo_.prior.mean)'/oo_.prior.variance*(dxparam1(:,jp));
|
||||
df(:,jp)=df(:,jp)+(dxparam1(:,jp))'/oo_.mom.prior.variance*(xparam1-oo_.mom.prior.mean)+(xparam1-oo_.mom.prior.mean)'/oo_.mom.prior.variance*(dxparam1(:,jp));
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -400,6 +400,19 @@ M_ = set_all_parameters(xparam0,estim_params_,M_);
|
|||
% provide warning if there is NaN in parameters
|
||||
test_for_deep_parameters_calibration(M_);
|
||||
|
||||
if doBayesianEstimation
|
||||
% warning if prior allows that stderr parameters are negative or corr parameters are outside the unit circle
|
||||
check_prior_stderr_corr(estim_params_,bayestopt_);
|
||||
|
||||
% check value of prior density
|
||||
[~,~,~,info]= priordens(xparam0,bayestopt_.pshape,bayestopt_.p6,bayestopt_.p7,bayestopt_.p3,bayestopt_.p4);
|
||||
if any(info)
|
||||
fprintf('The prior density evaluated at the initial values is Inf for the following parameters: %s\n',bayestopt_.name{info,1})
|
||||
error('The initial value of the prior is -Inf!')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
% -------------------------------------------------------------------------
|
||||
% Step 4: Checks and transformations for data
|
||||
% -------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue