Removed globals from set_all_parameters routine.
parent
9ce6eeebc6
commit
0da05ae29d
|
@ -62,7 +62,7 @@ decomp = [];
|
||||||
nobs = size(options_.varobs,1);
|
nobs = size(options_.varobs,1);
|
||||||
smpl = size(Y,2);
|
smpl = size(Y,2);
|
||||||
|
|
||||||
set_all_parameters(xparam1);
|
M_ = set_all_parameters(xparam1,estim_params_,M_);
|
||||||
|
|
||||||
%------------------------------------------------------------------------------
|
%------------------------------------------------------------------------------
|
||||||
% 2. call model setup & reduction program
|
% 2. call model setup & reduction program
|
||||||
|
|
|
@ -135,7 +135,7 @@ end
|
||||||
for b=1:B
|
for b=1:B
|
||||||
%deep = GetOneDraw(NumberOfDraws,FirstMhFile,LastMhFile,FirstLine,MAX_nruns,DirectoryName);
|
%deep = GetOneDraw(NumberOfDraws,FirstMhFile,LastMhFile,FirstLine,MAX_nruns,DirectoryName);
|
||||||
[deep, logpo] = GetOneDraw(type);
|
[deep, logpo] = GetOneDraw(type);
|
||||||
set_all_parameters(deep);
|
M_ = set_all_parameters(deep,estim_params_,M_);
|
||||||
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
[alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = ...
|
[alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = ...
|
||||||
DsgeSmoother(deep,gend,Y,data_index);
|
DsgeSmoother(deep,gend,Y,data_index);
|
||||||
|
|
|
@ -890,7 +890,7 @@ if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ...
|
||||||
prior_posterior_statistics('posterior',dataset_);
|
prior_posterior_statistics('posterior',dataset_);
|
||||||
end
|
end
|
||||||
xparam = get_posterior_parameters('mean');
|
xparam = get_posterior_parameters('mean');
|
||||||
set_all_parameters(xparam);
|
M_ = set_all_parameters(xparam,estim_params_,M_);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,7 @@ end
|
||||||
M_.dname = M_.fname;
|
M_.dname = M_.fname;
|
||||||
|
|
||||||
if info==1% Prior simulations (BK).
|
if info==1% Prior simulations (BK).
|
||||||
results = prior_sampler(0,M_,bayestopt_,options_,oo_);
|
results = prior_sampler(0,M_,bayestopt_,options_,oo_,estim_params_);
|
||||||
% Display prior mass info
|
% Display prior mass info
|
||||||
disp(['Prior mass = ' num2str(results.prior.mass)])
|
disp(['Prior mass = ' num2str(results.prior.mass)])
|
||||||
disp(['BK indeterminacy share = ' num2str(results.bk.indeterminacy_share)])
|
disp(['BK indeterminacy share = ' num2str(results.bk.indeterminacy_share)])
|
||||||
|
|
|
@ -112,12 +112,12 @@ else
|
||||||
end
|
end
|
||||||
if ~loadSA,
|
if ~loadSA,
|
||||||
if exist('xparam1','var')
|
if exist('xparam1','var')
|
||||||
set_all_parameters(xparam1);
|
M_ = set_all_parameters(xparam1,estim_params_,M_);
|
||||||
steady_(M_,options_,oo_);
|
steady_(M_,options_,oo_);
|
||||||
ys_mode=oo_.steady_state;
|
ys_mode=oo_.steady_state;
|
||||||
end
|
end
|
||||||
if exist('xparam1_mean','var')
|
if exist('xparam1_mean','var')
|
||||||
set_all_parameters(xparam1_mean);
|
M_ = set_all_parameters(xparam1_mean,estim_params_,M_);
|
||||||
steady_(M_,options_,oo_);
|
steady_(M_,options_,oo_);
|
||||||
ys_mean=oo_.steady_state;
|
ys_mean=oo_.steady_state;
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,7 +48,7 @@ persistent indH indJJ indLRE
|
||||||
nparam=length(params);
|
nparam=length(params);
|
||||||
np=length(indx);
|
np=length(indx);
|
||||||
offset=nparam-np;
|
offset=nparam-np;
|
||||||
set_all_parameters(params);
|
M_ = set_all_parameters(params,estim_params_,M_);
|
||||||
|
|
||||||
nlags = options_ident.ar;
|
nlags = options_ident.ar;
|
||||||
useautocorr = options_ident.useautocorr;
|
useautocorr = options_ident.useautocorr;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
function oo_ = prior_analysis(type,arg1,arg2,arg3,options_,M_,oo_)
|
function oo_ = prior_analysis(type,arg1,arg2,arg3,options_,M_,oo_,estim_params_)
|
||||||
% Copyright (C) 2009 Dynare Team
|
% Copyright (C) 2009 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
|
@ -28,7 +28,7 @@ switch info
|
||||||
drsave=1;
|
drsave=1;
|
||||||
end
|
end
|
||||||
load([M_.dname '/prior/definition.mat']);
|
load([M_.dname '/prior/definition.mat']);
|
||||||
prior_sampler(drsave,M_,bayestopt_,options_,oo_);
|
prior_sampler(drsave,M_,bayestopt_,options_,oo_,estim_params_);
|
||||||
clear('bayestopt_');
|
clear('bayestopt_');
|
||||||
oo_ = job(type,SampleSize,arg1,arg2,arg3,options_,M_,oo_);
|
oo_ = job(type,SampleSize,arg1,arg2,arg3,options_,M_,oo_);
|
||||||
case {4,5}
|
case {4,5}
|
||||||
|
|
|
@ -149,7 +149,7 @@ for b=fpar:B
|
||||||
logpo = evaluate_posterior_kernel(deep');
|
logpo = evaluate_posterior_kernel(deep');
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
set_all_parameters(deep);
|
M_ = set_all_parameters(deep,estim_params_,M_);
|
||||||
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
|
|
||||||
if run_smoother
|
if run_smoother
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
function results = prior_sampler(drsave,M_,bayestopt_,options_,oo_)
|
function results = prior_sampler(drsave,M_,bayestopt_,options_,oo_,estim_params_)
|
||||||
% This function builds a (big) prior sample.
|
% This function builds a (big) prior sample.
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
|
@ -79,7 +79,7 @@ file_indx_number = 0;
|
||||||
while iteration < NumberOfSimulations
|
while iteration < NumberOfSimulations
|
||||||
loop_indx = loop_indx+1;
|
loop_indx = loop_indx+1;
|
||||||
params = prior_draw();
|
params = prior_draw();
|
||||||
set_all_parameters(params);
|
M_ = set_all_parameters(params,estim_params_,M_);
|
||||||
[dr,INFO,M_,options_,oo_] = resol(work,M_,options_,oo_);
|
[dr,INFO,M_,options_,oo_] = resol(work,M_,options_,oo_);
|
||||||
switch INFO(1)
|
switch INFO(1)
|
||||||
case 0
|
case 0
|
||||||
|
|
|
@ -1,18 +1,39 @@
|
||||||
function set_all_parameters(xparam1)
|
function M = set_all_parameters(xparam1,estim_params,M)
|
||||||
|
|
||||||
% function set_all_parameters(xparam1)
|
%@info:
|
||||||
% Sets parameters value
|
%! @deftypefn {Function File} {@var{M} =} dynSeries (@var{xparams1},@var{estim_params},@var{M})
|
||||||
%
|
%! @anchor{set_all_parameters}
|
||||||
% INPUTS
|
%! @sp 1
|
||||||
% xparam1: vector of parameters to be estimated (initial values)
|
%! Update parameter values (deep parameters and covariance matrices).
|
||||||
%
|
%! @sp 2
|
||||||
% OUTPUTS
|
%! @strong{Inputs}
|
||||||
% none
|
%! @sp 1
|
||||||
%
|
%! @table @ @var
|
||||||
% SPECIAL REQUIREMENTS
|
%! @item xparam1
|
||||||
% none
|
%! N*1 vector of doubles, the values of the N estimated parameters.
|
||||||
|
%! @item estim_params
|
||||||
|
%! Dynare structure describing the estimated parameters.
|
||||||
|
%! @item M
|
||||||
|
%! Dynare structure describing the model.
|
||||||
|
%! @end table
|
||||||
|
%! @sp 1
|
||||||
|
%! @strong{Outputs}
|
||||||
|
%! @sp 1
|
||||||
|
%! @table @ @var
|
||||||
|
%! @item M
|
||||||
|
%! Dynare structure describing the model, with updated parameters and covariances matrices.
|
||||||
|
%! @end table
|
||||||
|
%! @sp 2
|
||||||
|
%! @strong{This function is called by:}
|
||||||
|
%! @sp 1
|
||||||
|
%! @ref{DsgeSmoother}, @ref{dynare_estimation_1}, @ref{@@gsa/filt_mc_}, @ref{identification_analysis}, @ref{PosteriorFilterSmootherAndForecast}, @ref{prior_posterior_statistics_core}, @ref{prior_sampler}
|
||||||
|
%! @sp 2
|
||||||
|
%! @strong{This function calls:}
|
||||||
|
%! @sp 2
|
||||||
|
%! @end deftypefn
|
||||||
|
%@eod:
|
||||||
|
|
||||||
% Copyright (C) 2003-2009 Dynare Team
|
% Copyright (C) 2003-2009, 2012 Dynare Team
|
||||||
%
|
%
|
||||||
% This file is part of Dynare.
|
% This file is part of Dynare.
|
||||||
%
|
%
|
||||||
|
@ -29,19 +50,17 @@ function set_all_parameters(xparam1)
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
global estim_params_ M_
|
nvx = estim_params.nvx;
|
||||||
|
ncx = estim_params.ncx;
|
||||||
nvx = estim_params_.nvx;
|
nvn = estim_params.nvn;
|
||||||
ncx = estim_params_.ncx;
|
ncn = estim_params.ncn;
|
||||||
nvn = estim_params_.nvn;
|
np = estim_params.np;
|
||||||
ncn = estim_params_.ncn;
|
Sigma_e = M.Sigma_e;
|
||||||
np = estim_params_.np;
|
H = M.H;
|
||||||
Sigma_e = M_.Sigma_e;
|
|
||||||
H = M_.H;
|
|
||||||
|
|
||||||
% setting shocks variance
|
% setting shocks variance
|
||||||
if nvx
|
if nvx
|
||||||
var_exo = estim_params_.var_exo;
|
var_exo = estim_params.var_exo;
|
||||||
for i=1:nvx
|
for i=1:nvx
|
||||||
k =var_exo(i,1);
|
k =var_exo(i,1);
|
||||||
Sigma_e(k,k) = xparam1(i)^2;
|
Sigma_e(k,k) = xparam1(i)^2;
|
||||||
|
@ -52,7 +71,7 @@ offset = nvx;
|
||||||
|
|
||||||
% setting measument error variance
|
% setting measument error variance
|
||||||
if nvn
|
if nvn
|
||||||
var_endo = estim_params_.var_endo;
|
var_endo = estim_params.var_endo;
|
||||||
for i=1:nvn
|
for i=1:nvn
|
||||||
k = var_endo(i,1);
|
k = var_endo(i,1);
|
||||||
H(k,k) = xparam1(i+offset)^2;
|
H(k,k) = xparam1(i+offset)^2;
|
||||||
|
@ -63,16 +82,16 @@ end
|
||||||
offset = nvx+nvn;
|
offset = nvx+nvn;
|
||||||
|
|
||||||
% setting shocks covariances
|
% setting shocks covariances
|
||||||
if ~isempty(M_.Correlation_matrix)
|
if ~isempty(M.Correlation_matrix)
|
||||||
Sigma_e = diag(sqrt(diag(Sigma_e)))*M_.Correlation_matrix*diag(sqrt(diag(Sigma_e)));
|
Sigma_e = diag(sqrt(diag(Sigma_e)))*M.Correlation_matrix*diag(sqrt(diag(Sigma_e)));
|
||||||
end
|
end
|
||||||
if ncx
|
if ncx
|
||||||
corrx = estim_params_.corrx;
|
corrx = estim_params.corrx;
|
||||||
for i=1:ncx
|
for i=1:ncx
|
||||||
k1 = corrx(i,1);
|
k1 = corrx(i,1);
|
||||||
k2 = corrx(i,2);
|
k2 = corrx(i,2);
|
||||||
M_.Correlation_matrix(k1,k2) = xparam1(i+offset);
|
M.Correlation_matrix(k1,k2) = xparam1(i+offset);
|
||||||
M_.Correlation_matrix(k2,k1) = M_.Correlation_matrix(k1,k2);
|
M.Correlation_matrix(k2,k1) = M.Correlation_matrix(k1,k2);
|
||||||
Sigma_e(k1,k2) = xparam1(i+offset)*sqrt(Sigma_e(k1,k1)*Sigma_e(k2,k2));
|
Sigma_e(k1,k2) = xparam1(i+offset)*sqrt(Sigma_e(k1,k1)*Sigma_e(k2,k2));
|
||||||
Sigma_e(k2,k1) = Sigma_e(k1,k2);
|
Sigma_e(k2,k1) = Sigma_e(k1,k2);
|
||||||
end
|
end
|
||||||
|
@ -82,7 +101,7 @@ end
|
||||||
offset = nvx+nvn+ncx;
|
offset = nvx+nvn+ncx;
|
||||||
% setting measurement error covariances
|
% setting measurement error covariances
|
||||||
if ncn
|
if ncn
|
||||||
corrn = estim_params_.corrn;
|
corrn = estim_params.corrn;
|
||||||
for i=1:ncn
|
for i=1:ncn
|
||||||
k1 = corr(i,1);
|
k1 = corr(i,1);
|
||||||
k2 = corr(i,2);
|
k2 = corr(i,2);
|
||||||
|
@ -96,13 +115,13 @@ offset = nvx+ncx+nvn+ncn;
|
||||||
% setting structural parameters
|
% setting structural parameters
|
||||||
%
|
%
|
||||||
if np
|
if np
|
||||||
M_.params(estim_params_.param_vals(:,1)) = xparam1(offset+1:end);
|
M.params(estim_params.param_vals(:,1)) = xparam1(offset+1:end);
|
||||||
end
|
end
|
||||||
|
|
||||||
% updating matrices in M_
|
% updating matrices in M
|
||||||
if nvx
|
if nvx || ncx
|
||||||
M_.Sigma_e = Sigma_e;
|
M.Sigma_e = Sigma_e;
|
||||||
end
|
end
|
||||||
if nvn
|
if nvn
|
||||||
M_.H = H;
|
M.H = H;
|
||||||
end
|
end
|
Loading…
Reference in New Issue