commit
25f6d81cb7
|
@ -230,10 +230,10 @@ if init,
|
||||||
end
|
end
|
||||||
|
|
||||||
case 'mode_files'
|
case 'mode_files'
|
||||||
% for multimodal posteriors provide a list of mode files,
|
% for multimodal posteriors provide the name of
|
||||||
% one per mode. With this info, the code will automatically
|
% a file containing a variable array xparams = [nparam * nmodes]
|
||||||
% set the <mode> option. The mode files need only to
|
% one column per mode. With this info, the code will automatically
|
||||||
% contain the xparam1 variable.
|
% set the <mode> option.
|
||||||
% This will automatically trigger <rotated>
|
% This will automatically trigger <rotated>
|
||||||
% default = []
|
% default = []
|
||||||
posterior_sampler_options.mode_files = options_list{i,2};
|
posterior_sampler_options.mode_files = options_list{i,2};
|
||||||
|
@ -326,9 +326,12 @@ if init,
|
||||||
|
|
||||||
if ~isempty(posterior_sampler_options.mode_files), % multimodal case
|
if ~isempty(posterior_sampler_options.mode_files), % multimodal case
|
||||||
modes = posterior_sampler_options.mode_files; % these can be also mean files from previous parallel slice chains
|
modes = posterior_sampler_options.mode_files; % these can be also mean files from previous parallel slice chains
|
||||||
for j=1:length( modes ),
|
load(modes, 'xparams')
|
||||||
load(modes{j}, 'xparam1')
|
if size(xparams,2)<2,
|
||||||
mode(j).m=xparam1;
|
error(['check_posterior_sampler_options:: Variable xparams loaded in file <' modes '> has size [' int2str(size(xparams,1)) 'x' int2str(size(xparams,2)) ']: it must contain at least two columns, to allow multi-modal sampling.'])
|
||||||
|
end
|
||||||
|
for j=1:size(xparams,2),
|
||||||
|
mode(j).m=xparams(:,j);
|
||||||
end
|
end
|
||||||
posterior_sampler_options.mode = mode;
|
posterior_sampler_options.mode = mode;
|
||||||
posterior_sampler_options.rotated = 1;
|
posterior_sampler_options.rotated = 1;
|
||||||
|
|
|
@ -546,10 +546,10 @@ if analytic_derivation,
|
||||||
end
|
end
|
||||||
|
|
||||||
if full_Hess,
|
if full_Hess,
|
||||||
[dum, DT, DOm, DYss, dum2, D2T, D2Om, D2Yss] = getH(A, B, Model,DynareResults,DynareOptions,kron_flag,indparam,indexo,iv);
|
[dum, DT, DOm, DYss, dum2, D2T, D2Om, D2Yss] = getH(A, B, EstimatedParameters, Model,DynareResults,DynareOptions,kron_flag,indparam,indexo,iv);
|
||||||
clear dum dum2;
|
clear dum dum2;
|
||||||
else
|
else
|
||||||
[dum, DT, DOm, DYss] = getH(A, B, Model,DynareResults,DynareOptions,kron_flag,indparam,indexo,iv);
|
[dum, DT, DOm, DYss] = getH(A, B, EstimatedParameters, Model,DynareResults,DynareOptions,kron_flag,indparam,indexo,iv);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
DT = derivatives_info.DT(iv,iv,:);
|
DT = derivatives_info.DT(iv,iv,:);
|
||||||
|
|
|
@ -187,10 +187,18 @@ if prior_exist,
|
||||||
name = bayestopt_.name;
|
name = bayestopt_.name;
|
||||||
name_tex = char(M_.exo_names_tex(indexo,:),M_.param_names_tex(indx,:));
|
name_tex = char(M_.exo_names_tex(indexo,:),M_.param_names_tex(indx,:));
|
||||||
|
|
||||||
|
if estim_params_.nvn || estim_params_.ncn,
|
||||||
|
error('Identification does not support measurement errors. Instead, define them explicitly in measurement equations in model definition.')
|
||||||
|
else
|
||||||
offset = estim_params_.nvx;
|
offset = estim_params_.nvx;
|
||||||
offset = offset + estim_params_.nvn;
|
%offset = offset + estim_params_.nvn;
|
||||||
offset = offset + estim_params_.ncx;
|
offset = offset + estim_params_.ncx;
|
||||||
offset = offset + estim_params_.ncn;
|
if estim_params_.ncx
|
||||||
|
options_ident.analytic_derivation=0;
|
||||||
|
options_ident.analytic_derivation_mode=-1;
|
||||||
|
end
|
||||||
|
%offset = offset + estim_params_.ncn;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
indx = [1:M_.param_nbr];
|
indx = [1:M_.param_nbr];
|
||||||
indexo = [1:M_.exo_nbr];
|
indexo = [1:M_.exo_nbr];
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function [H, dA, dOm, Hss, gp, d2A, d2Om, H2ss] = getH(A, B, M_,oo_,options_,kronflag,indx,indexo,iv)
|
function [H, dA, dOm, Hss, gp, d2A, d2Om, H2ss] = getH(A, B, estim_params_,M_,oo_,options_,kronflag,indx,indexo,iv)
|
||||||
% function [H, dA, dOm, Hss, gp, d2A, d2Om, H2ss] = getH(A, B, M_,oo_,options_,kronflag,indx,indexo,iv)
|
% function [H, dA, dOm, Hss, gp, d2A, d2Om, H2ss] = getH(A, B, estim_params_,M_,oo_,options_,kronflag,indx,indexo,iv)
|
||||||
% computes derivative of reduced form linear model w.r.t. deep params
|
% computes derivative of reduced form linear model w.r.t. deep params
|
||||||
%
|
%
|
||||||
% Inputs:
|
% Inputs:
|
||||||
|
@ -49,16 +49,16 @@ function [H, dA, dOm, Hss, gp, d2A, d2Om, H2ss] = getH(A, B, M_,oo_,options_,kro
|
||||||
% 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/>.
|
||||||
|
|
||||||
if nargin<6 || isempty(kronflag)
|
if nargin<7 || isempty(kronflag)
|
||||||
kronflag = 0;
|
kronflag = 0;
|
||||||
end
|
end
|
||||||
if nargin<7 || isempty(indx)
|
if nargin<8 || isempty(indx)
|
||||||
indx = [];
|
indx = [];
|
||||||
end
|
end
|
||||||
if nargin<8 || isempty(indexo)
|
if nargin<9 || isempty(indexo)
|
||||||
indexo = [];
|
indexo = [];
|
||||||
end
|
end
|
||||||
if nargin<9 || isempty(iv)
|
if nargin<10 || isempty(iv)
|
||||||
iv = (1:length(A))';
|
iv = (1:length(A))';
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ if kronflag==-1, % perturbation
|
||||||
end
|
end
|
||||||
if nargout>5,
|
if nargout>5,
|
||||||
H2 = hessian_sparse('thet2tau',[sqrt(diag(M_.Sigma_e(indexo,indexo))); M_.params(indx)], ...
|
H2 = hessian_sparse('thet2tau',[sqrt(diag(M_.Sigma_e(indexo,indexo))); M_.params(indx)], ...
|
||||||
options_.gstep,M_, oo_, indx,indexo,0,[],[],[],iv);
|
options_.gstep,estim_params_,M_, oo_, indx,indexo,0,[],[],[],iv);
|
||||||
H2ss = zeros(m1,tot_param_nbr,tot_param_nbr);
|
H2ss = zeros(m1,tot_param_nbr,tot_param_nbr);
|
||||||
iax=find(triu(rand(tot_param_nbr,tot_param_nbr)));
|
iax=find(triu(rand(tot_param_nbr,tot_param_nbr)));
|
||||||
H2 = H2(:,iax);
|
H2 = H2(:,iax);
|
||||||
|
@ -126,7 +126,7 @@ if kronflag==-2,
|
||||||
if nargout>5,
|
if nargout>5,
|
||||||
[residual, g1, g2 ] = feval([M_.fname,'_dynamic'],yy0, oo_.exo_steady_state', ...
|
[residual, g1, g2 ] = feval([M_.fname,'_dynamic'],yy0, oo_.exo_steady_state', ...
|
||||||
M_.params, oo_.dr.ys, 1);
|
M_.params, oo_.dr.ys, 1);
|
||||||
g22 = hessian_sparse('thet2tau',[M_.params(indx)],options_.gstep,M_, oo_, indx,[],-1);
|
g22 = hessian_sparse('thet2tau',[M_.params(indx)],options_.gstep,estim_params_,M_, oo_, indx,[],-1);
|
||||||
H2ss=full(g22(1:M_.endo_nbr,:));
|
H2ss=full(g22(1:M_.endo_nbr,:));
|
||||||
H2ss = reshape(H2ss,[M_.endo_nbr param_nbr param_nbr]);
|
H2ss = reshape(H2ss,[M_.endo_nbr param_nbr param_nbr]);
|
||||||
for j=1:M_.endo_nbr,
|
for j=1:M_.endo_nbr,
|
||||||
|
@ -147,7 +147,7 @@ if kronflag==-2,
|
||||||
[residual, g1 ] = feval([M_.fname,'_dynamic'],yy0, oo_.exo_steady_state', ...
|
[residual, g1 ] = feval([M_.fname,'_dynamic'],yy0, oo_.exo_steady_state', ...
|
||||||
M_.params, oo_.dr.ys, 1);
|
M_.params, oo_.dr.ys, 1);
|
||||||
end
|
end
|
||||||
gp = fjaco('thet2tau',[M_.params(indx)],M_, oo_, indx,[],-1);
|
gp = fjaco('thet2tau',[M_.params(indx)],estim_params_,M_, oo_, indx,[],-1);
|
||||||
Hss=gp(1:M_.endo_nbr,:);
|
Hss=gp(1:M_.endo_nbr,:);
|
||||||
gp=gp(M_.endo_nbr+1:end,:);
|
gp=gp(M_.endo_nbr+1:end,:);
|
||||||
gp = reshape(gp,[size(g1) param_nbr]);
|
gp = reshape(gp,[size(g1) param_nbr]);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function [JJ, H, gam, gp, dA, dOm, dYss] = getJJ(A, B, M_,oo_,options_,kronflag,indx,indexo,mf,nlags,useautocorr)
|
function [JJ, H, gam, gp, dA, dOm, dYss] = getJJ(A, B, estim_params_, M_,oo_,options_,kronflag,indx,indexo,mf,nlags,useautocorr)
|
||||||
% function [JJ, H, gam, gp, dA, dOm, dYss] = getJJ(A, B, M_,oo_,options_,kronflag,indx,indexo,mf,nlags,useautocorr)
|
% function [JJ, H, gam, gp, dA, dOm, dYss] = getJJ(A, B, estim_params_, M_,oo_,options_,kronflag,indx,indexo,mf,nlags,useautocorr)
|
||||||
% computes derivatives of 1st and 2nd order moments of observables with
|
% computes derivatives of 1st and 2nd order moments of observables with
|
||||||
% respect to estimated parameters
|
% respect to estimated parameters
|
||||||
%
|
%
|
||||||
|
@ -54,16 +54,16 @@ function [JJ, H, gam, gp, dA, dOm, dYss] = getJJ(A, B, M_,oo_,options_,kronflag,
|
||||||
% 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/>.
|
||||||
|
|
||||||
if nargin<7 || isempty(indx)
|
if nargin<8 || isempty(indx)
|
||||||
% indx = [1:M_.param_nbr];
|
% indx = [1:M_.param_nbr];
|
||||||
end,
|
end,
|
||||||
if nargin<8 || isempty(indexo)
|
if nargin<9 || isempty(indexo)
|
||||||
indexo = [];
|
indexo = [];
|
||||||
end,
|
end,
|
||||||
if nargin<10 || isempty(nlags)
|
if nargin<11 || isempty(nlags)
|
||||||
nlags=3;
|
nlags=3;
|
||||||
end
|
end
|
||||||
if nargin<11 || isempty(useautocorr)
|
if nargin<12 || isempty(useautocorr)
|
||||||
useautocorr=0;
|
useautocorr=0;
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -73,15 +73,16 @@ warning('off','MATLAB:divideByZero')
|
||||||
if kronflag == -1,
|
if kronflag == -1,
|
||||||
fun = 'thet2tau';
|
fun = 'thet2tau';
|
||||||
params0 = M_.params;
|
params0 = M_.params;
|
||||||
JJ = fjaco(fun,[sqrt(diag(M_.Sigma_e(indexo,indexo))); M_.params(indx)],M_, oo_, indx,indexo,1,mf,nlags,useautocorr);
|
para0 = get_all_parameters(estim_params_, M_);
|
||||||
|
JJ = fjaco(fun,para0,estim_params_,M_, oo_, indx,indexo,1,mf,nlags,useautocorr);
|
||||||
M_.params = params0;
|
M_.params = params0;
|
||||||
params0 = M_.params;
|
params0 = M_.params;
|
||||||
H = fjaco(fun,[sqrt(diag(M_.Sigma_e(indexo,indexo))); M_.params(indx)],M_, oo_, indx,indexo,0,mf,nlags,useautocorr);
|
H = fjaco(fun,para0,estim_params_,M_, oo_, indx,indexo,0,mf,nlags,useautocorr);
|
||||||
M_.params = params0;
|
M_.params = params0;
|
||||||
params0 = M_.params;
|
params0 = M_.params;
|
||||||
gp = fjaco(fun,[sqrt(diag(M_.Sigma_e(indexo,indexo))); M_.params(indx)],M_, oo_, indx,indexo,-1);
|
gp = fjaco(fun,para0,estim_params_,M_, oo_, indx,indexo,-1);
|
||||||
M_.params = params0;
|
M_.params = params0;
|
||||||
offset = length(indexo);
|
offset = length(para0)-length(indx);
|
||||||
gp = gp(:,offset+1:end);
|
gp = gp(:,offset+1:end);
|
||||||
dYss = H(1:M_.endo_nbr,offset+1:end);
|
dYss = H(1:M_.endo_nbr,offset+1:end);
|
||||||
dA = reshape(H(M_.orig_endo_nbr+[1:numel(A)],:),[size(A),size(H,2)]);
|
dA = reshape(H(M_.orig_endo_nbr+[1:numel(A)],:),[size(A),size(H,2)]);
|
||||||
|
@ -92,7 +93,7 @@ if kronflag == -1,
|
||||||
assignin('base','M_', M_);
|
assignin('base','M_', M_);
|
||||||
assignin('base','oo_', oo_);
|
assignin('base','oo_', oo_);
|
||||||
else
|
else
|
||||||
[H, dA, dOm, dYss, gp] = getH(A, B, M_,oo_,options_,kronflag,indx,indexo);
|
[H, dA, dOm, dYss, gp] = getH(A, B, estim_params_,M_,oo_,options_,kronflag,indx,indexo);
|
||||||
gp = reshape(gp,size(gp,1)*size(gp,2),size(gp,3));
|
gp = reshape(gp,size(gp,1)*size(gp,2),size(gp,3));
|
||||||
gp = [dYss; gp];
|
gp = [dYss; gp];
|
||||||
% if isempty(H),
|
% if isempty(H),
|
||||||
|
|
|
@ -80,7 +80,7 @@ if info(1)==0,
|
||||||
oo_.dr.ys, 1);
|
oo_.dr.ys, 1);
|
||||||
vg1 = [oo_.dr.ys(oo_.dr.order_var); vec(g1)];
|
vg1 = [oo_.dr.ys(oo_.dr.order_var); vec(g1)];
|
||||||
|
|
||||||
[JJ, H, gam, gp, dA, dOm, dYss] = getJJ(A, B, M_,oo0,options_,kron_flag,indx,indexo,bayestopt_.mf2,nlags,useautocorr);
|
[JJ, H, gam, gp, dA, dOm, dYss] = getJJ(A, B, estim_params_, M_,oo0,options_,kron_flag,indx,indexo,bayestopt_.mf2,nlags,useautocorr);
|
||||||
derivatives_info.DT=dA;
|
derivatives_info.DT=dA;
|
||||||
derivatives_info.DOm=dOm;
|
derivatives_info.DOm=dOm;
|
||||||
derivatives_info.DYss=dYss;
|
derivatives_info.DYss=dYss;
|
||||||
|
@ -95,7 +95,7 @@ if info(1)==0,
|
||||||
disp('The number of moments with non-zero derivative is smaller than the number of parameters')
|
disp('The number of moments with non-zero derivative is smaller than the number of parameters')
|
||||||
disp(['Try increasing ar = ', int2str(nlags+1)])
|
disp(['Try increasing ar = ', int2str(nlags+1)])
|
||||||
nlags=nlags+1;
|
nlags=nlags+1;
|
||||||
[JJ, H, gam, gp, dA, dOm, dYss] = getJJ(A, B, M_,oo0,options_,kron_flag,indx,indexo,bayestopt_.mf2,nlags,useautocorr);
|
[JJ, H, gam, gp, dA, dOm, dYss] = getJJ(A, B, estim_params_, M_,oo0,options_,kron_flag,indx,indexo,bayestopt_.mf2,nlags,useautocorr);
|
||||||
derivatives_info.DT=dA;
|
derivatives_info.DT=dA;
|
||||||
derivatives_info.DOm=dOm;
|
derivatives_info.DOm=dOm;
|
||||||
derivatives_info.DYss=dYss;
|
derivatives_info.DYss=dYss;
|
||||||
|
@ -127,6 +127,9 @@ if info(1)==0,
|
||||||
else
|
else
|
||||||
normaliz1=[];
|
normaliz1=[];
|
||||||
end
|
end
|
||||||
|
if ~isempty(estim_params_.corrx),
|
||||||
|
normaliz1 = [normaliz1 estim_params_.corrx(:,8)']; % normalize with prior standard deviation
|
||||||
|
end
|
||||||
if ~isempty(estim_params_.param_vals),
|
if ~isempty(estim_params_.param_vals),
|
||||||
normaliz1 = [normaliz1 estim_params_.param_vals(:,7)']; % normalize with prior standard deviation
|
normaliz1 = [normaliz1 estim_params_.param_vals(:,7)']; % normalize with prior standard deviation
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
function tau = thet2tau(params, M_, oo_, indx, indexo, flagmoments,mf,nlags,useautocorr,iv)
|
function tau = thet2tau(params, estim_params_, M_, oo_, indx, indexo, flagmoments,mf,nlags,useautocorr,iv)
|
||||||
|
|
||||||
%
|
%
|
||||||
% Copyright (C) 2011-2012 Dynare Team
|
% Copyright (C) 2011-2012 Dynare Team
|
||||||
|
@ -25,20 +25,24 @@ if nargin==1,
|
||||||
indexo = [];
|
indexo = [];
|
||||||
end
|
end
|
||||||
|
|
||||||
if nargin<6,
|
if nargin<7,
|
||||||
flagmoments=0;
|
flagmoments=0;
|
||||||
end
|
end
|
||||||
if nargin<9 || isempty(useautocorr),
|
if nargin<10 || isempty(useautocorr),
|
||||||
useautocorr=0;
|
useautocorr=0;
|
||||||
end
|
end
|
||||||
if nargin<10 || isempty(iv),
|
if nargin<11 || isempty(iv),
|
||||||
iv=[1:M_.endo_nbr];
|
iv=[1:M_.endo_nbr];
|
||||||
end
|
end
|
||||||
|
|
||||||
M_.params(indx) = params(length(indexo)+1:end);
|
if length(params)>length(indx),
|
||||||
if ~isempty(indexo)
|
M_ = set_all_parameters(params,estim_params_,M_);
|
||||||
M_.Sigma_e(indexo,indexo) = diag(params(1:length(indexo)).^2);
|
else
|
||||||
|
M_.params(indx) = params;
|
||||||
end
|
end
|
||||||
|
% if ~isempty(indexo)
|
||||||
|
% M_.Sigma_e(indexo,indexo) = diag(params(1:length(indexo)).^2);
|
||||||
|
% end
|
||||||
[A,B,tele,tubbies,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
|
[A,B,tele,tubbies,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
|
||||||
if flagmoments==0,
|
if flagmoments==0,
|
||||||
ys=oo_.dr.ys(oo_.dr.order_var);
|
ys=oo_.dr.ys(oo_.dr.order_var);
|
||||||
|
|
Loading…
Reference in New Issue