v4 bug corrections in dealing with measurement errors

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1708 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
michel 2008-02-16 17:02:39 +00:00
parent 0dd30038cb
commit c7dc3ca3bc
3 changed files with 42 additions and 19 deletions

View File

@ -910,7 +910,7 @@ if (any(bayestopt_.pshape >0 ) & options_.mh_replic) | ...
end
xparam = get_posterior_parameters('mean');
set_parameters(xparam);
set_all_parameters(xparam);
% return
end

View File

@ -25,6 +25,7 @@ function set_all_parameters(xparam1)
Sigma_e = M_.Sigma_e;
H = M_.H;
% setting shocks variance
if nvx
var_exo = estim_params_.var_exo;
for i=1:nvx
@ -32,9 +33,23 @@ function set_all_parameters(xparam1)
Sigma_e(k,k) = xparam1(i)^2;
end
end
% update offset
offset = nvx
% setting measument error variance
if nvn
var_endo = estim_params_.var_endo;
for i=1:nvn
k = var_endo(i,1);
H(k,k) = xparam1(i+offset)^2;
end
end
% update offset
offset = nvx+nvn;
% setting shocks covariances
if ncx
offset = nvx+nvn;
corrx = estim_params_.corrx;
for i=1:ncx
k1 = corrx(i,1);
@ -44,17 +59,10 @@ function set_all_parameters(xparam1)
end
end
if nvn
offset = nvx;
var_endo = estim_params_.var_endo;
for i=1:nvn
k = var_endo(i,1);
H(k,k) = xparam1(i+offset)^2;
end
end
if ncn
% update offset
offset = nvx+nvn+ncx;
% setting measurement error covariances
if ncn
corrn = estim_params_.corrn;
for i=1:ncn
k1 = corr(i,1);
@ -64,11 +72,15 @@ function set_all_parameters(xparam1)
end
end
% update offset
offset = nvx+ncx+nvn+ncn;
% setting structural parameters
%
if np
offset = nvx+ncx+nvn+ncn;
M_.params(estim_params_.param_vals(:,1)) = xparam1(offset+1:end);
end
% updating matrices in M_
if nvx
M_.Sigma_e = Sigma_e;
end

View File

@ -2,6 +2,8 @@ function set_parameters(xparam1)
% function set_parameters(xparam1)
% Sets parameters value (except measurement errors)
% This is called for computations such as IRF and forecast
% when measurement errors aren't taken into account
%
% INPUTS
% xparam1: vector of parameters to be estimated (initial values)
@ -17,22 +19,29 @@ function set_parameters(xparam1)
global estim_params_ M_
global estim_params_ M_
nvx = estim_params_.nvx;
ncx = estim_params_.ncx;
nvn = estim_params_.nvn;
ncn = estim_params_.ncn;
np = estim_params_.np;
Sigma_e = M_.Sigma_e;
offset = 0;
% stderrs of the exogenous shocks
if nvx
offset = offset + nvx;
var_exo = estim_params_.var_exo;
for i=1:nvx
k = var_exo(i,1);
Sigma_e(k,k) = xparam1(i)^2;
end
end
% and update offset
offset = offset + nvx + nvn;
% correlations amonx shocks (ncx)
if ncx
offset = offset + estim_params_.nvn;
corrx = estim_params_.corrx;
for i=1:ncx
k1 = corrx(i,1);
@ -41,10 +50,12 @@ function set_parameters(xparam1)
Sigma_e(k2,k1) = Sigma_e(k1,k2);
end
end
% and update offset
offset = offset + ncx + ncn;
% structural parameters
if np
offset = offset+estim_params_.ncx+estim_params_.ncn;
M_.params(estim_params_.param_vals(:,1)) = xparam1(offset+1:end);
end
M_.Sigma_e = Sigma_e;