Moving loading of MCMC_jumping_covariance to after display of standard errors and computation of Laplace approximation
Closes #1255time-shift
parent
4a93d0f9f0
commit
7b4fc9ec4a
|
@ -263,35 +263,6 @@ if ~isequal(options_.mode_compute,0) && ~options_.mh_posterior_mode_estimation
|
|||
end
|
||||
end
|
||||
|
||||
switch options_.MCMC_jumping_covariance
|
||||
case 'hessian' %Baseline
|
||||
%do nothing and use hessian from mode_compute
|
||||
case 'prior_variance' %Use prior variance
|
||||
if any(isinf(bayestopt_.p2))
|
||||
error('Infinite prior variances detected. You cannot use the prior variances as the proposal density, if some variances are Inf.')
|
||||
else
|
||||
hh = diag(1./(bayestopt_.p2.^2));
|
||||
end
|
||||
case 'identity_matrix' %Use identity
|
||||
hh = eye(nx);
|
||||
otherwise %user specified matrix in file
|
||||
try
|
||||
load(options_.MCMC_jumping_covariance,'jumping_covariance')
|
||||
hh=jumping_covariance;
|
||||
catch
|
||||
error(['No matrix named ''jumping_covariance'' could be found in ',options_.MCMC_jumping_covariance,'.mat'])
|
||||
end
|
||||
[nrow, ncol]=size(hh);
|
||||
if ~isequal(nrow,ncol) && ~isequal(nrow,nx) %check if square and right size
|
||||
error(['jumping_covariance matrix must be square and have ',num2str(nx),' rows and columns'])
|
||||
end
|
||||
try %check for positive definiteness
|
||||
chol(hh);
|
||||
catch
|
||||
error(['Specified jumping_covariance is not positive definite'])
|
||||
end
|
||||
end
|
||||
|
||||
if ~options_.mh_posterior_mode_estimation && options_.cova_compute
|
||||
try
|
||||
chol(hh);
|
||||
|
@ -393,6 +364,39 @@ if np > 0
|
|||
save([M_.fname '_params.mat'],'pindx');
|
||||
end
|
||||
|
||||
switch options_.MCMC_jumping_covariance
|
||||
case 'hessian' %Baseline
|
||||
%do nothing and use hessian from mode_compute
|
||||
case 'prior_variance' %Use prior variance
|
||||
if any(isinf(bayestopt_.p2))
|
||||
error('Infinite prior variances detected. You cannot use the prior variances as the proposal density, if some variances are Inf.')
|
||||
else
|
||||
hh = diag(1./(bayestopt_.p2.^2));
|
||||
end
|
||||
hsd = sqrt(diag(hh));
|
||||
invhess = inv(hh./(hsd*hsd'))./(hsd*hsd');
|
||||
case 'identity_matrix' %Use identity
|
||||
invhess = eye(nx);
|
||||
otherwise %user specified matrix in file
|
||||
try
|
||||
load(options_.MCMC_jumping_covariance,'jumping_covariance')
|
||||
hh=jumping_covariance;
|
||||
catch
|
||||
error(['No matrix named ''jumping_covariance'' could be found in ',options_.MCMC_jumping_covariance,'.mat'])
|
||||
end
|
||||
[nrow, ncol]=size(hh);
|
||||
if ~isequal(nrow,ncol) && ~isequal(nrow,nx) %check if square and right size
|
||||
error(['jumping_covariance matrix must be square and have ',num2str(nx),' rows and columns'])
|
||||
end
|
||||
try %check for positive definiteness
|
||||
chol(hh);
|
||||
hsd = sqrt(diag(hh));
|
||||
invhess = inv(hh./(hsd*hsd'))./(hsd*hsd');
|
||||
catch
|
||||
error(['Specified jumping_covariance is not positive definite'])
|
||||
end
|
||||
end
|
||||
|
||||
if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ...
|
||||
(any(bayestopt_.pshape >0 ) && options_.load_mh_file) %% not ML estimation
|
||||
bounds = prior_bounds(bayestopt_, options_.prior_trunc);
|
||||
|
|
Loading…
Reference in New Issue