Removed globals from resol.m (changed calling sequence). Added texinfo header.
Removed trailing whitespace.time-shift
parent
d81fd1b55b
commit
24cd423671
|
@ -5,14 +5,14 @@ function PosteriorFilterSmootherAndForecast(Y,gend, type,data_index)
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% Y: data
|
% Y: data
|
||||||
% gend: number of observations
|
% gend: number of observations
|
||||||
% type: posterior
|
% type: posterior
|
||||||
% prior
|
% prior
|
||||||
% gsa
|
% gsa
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% none
|
% none
|
||||||
%
|
%
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
% none
|
% none
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ CheckPath('Plots/');
|
||||||
DirectoryName = CheckPath('metropolis');
|
DirectoryName = CheckPath('metropolis');
|
||||||
load([ DirectoryName '/' M_.fname '_mh_history.mat'])
|
load([ DirectoryName '/' M_.fname '_mh_history.mat'])
|
||||||
FirstMhFile = record.KeepedDraws.FirstMhFile;
|
FirstMhFile = record.KeepedDraws.FirstMhFile;
|
||||||
FirstLine = record.KeepedDraws.FirstLine;
|
FirstLine = record.KeepedDraws.FirstLine;
|
||||||
TotalNumberOfMhFiles = sum(record.MhDraws(:,2)); LastMhFile = TotalNumberOfMhFiles;
|
TotalNumberOfMhFiles = sum(record.MhDraws(:,2)); LastMhFile = TotalNumberOfMhFiles;
|
||||||
TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
|
TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
|
||||||
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
|
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
|
||||||
clear record;
|
clear record;
|
||||||
|
@ -136,17 +136,17 @@ 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);
|
set_all_parameters(deep);
|
||||||
dr = resol(oo_.steady_state,0);
|
[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);
|
||||||
|
|
||||||
if options_.loglinear
|
if options_.loglinear
|
||||||
stock_smooth(dr.order_var,:,irun1) = alphahat(1:endo_nbr,:)+ ...
|
stock_smooth(dr.order_var,:,irun1) = alphahat(1:endo_nbr,:)+ ...
|
||||||
repmat(log(dr.ys(dr.order_var)),1,gend);
|
repmat(log(dr.ys(dr.order_var)),1,gend);
|
||||||
else
|
else
|
||||||
stock_smooth(dr.order_var,:,irun1) = alphahat(1:endo_nbr,:)+ ...
|
stock_smooth(dr.order_var,:,irun1) = alphahat(1:endo_nbr,:)+ ...
|
||||||
repmat(dr.ys(dr.order_var),1,gend);
|
repmat(dr.ys(dr.order_var),1,gend);
|
||||||
end
|
end
|
||||||
if nvx
|
if nvx
|
||||||
stock_innov(:,:,irun2) = etahat;
|
stock_innov(:,:,irun2) = etahat;
|
||||||
end
|
end
|
||||||
|
@ -191,7 +191,7 @@ for b=1:B
|
||||||
stock_forcst_mean(:,:,irun6) = yf';
|
stock_forcst_mean(:,:,irun6) = yf';
|
||||||
stock_forcst_total(:,:,irun7) = yf1';
|
stock_forcst_total(:,:,irun7) = yf1';
|
||||||
end
|
end
|
||||||
|
|
||||||
irun1 = irun1 + 1;
|
irun1 = irun1 + 1;
|
||||||
irun2 = irun2 + 1;
|
irun2 = irun2 + 1;
|
||||||
irun3 = irun3 + 1;
|
irun3 = irun3 + 1;
|
||||||
|
@ -206,28 +206,28 @@ for b=1:B
|
||||||
save([DirectoryName '/' M_.fname '_smooth' int2str(ifil1) '.mat'],'stock');
|
save([DirectoryName '/' M_.fname '_smooth' int2str(ifil1) '.mat'],'stock');
|
||||||
irun1 = 1;
|
irun1 = 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
if nvx && (irun2 > MAX_ninno || b == B)
|
if nvx && (irun2 > MAX_ninno || b == B)
|
||||||
stock = stock_innov(:,:,1:irun2-1);
|
stock = stock_innov(:,:,1:irun2-1);
|
||||||
ifil2 = ifil2 + 1;
|
ifil2 = ifil2 + 1;
|
||||||
save([DirectoryName '/' M_.fname '_inno' int2str(ifil2) '.mat'],'stock');
|
save([DirectoryName '/' M_.fname '_inno' int2str(ifil2) '.mat'],'stock');
|
||||||
irun2 = 1;
|
irun2 = 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
if nvn && (irun3 > MAX_error || b == B)
|
if nvn && (irun3 > MAX_error || b == B)
|
||||||
stock = stock_error(:,:,1:irun3-1);
|
stock = stock_error(:,:,1:irun3-1);
|
||||||
ifil3 = ifil3 + 1;
|
ifil3 = ifil3 + 1;
|
||||||
save([DirectoryName '/' M_.fname '_error' int2str(ifil3) '.mat'],'stock');
|
save([DirectoryName '/' M_.fname '_error' int2str(ifil3) '.mat'],'stock');
|
||||||
irun3 = 1;
|
irun3 = 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
if naK && (irun4 > MAX_naK || b == B)
|
if naK && (irun4 > MAX_naK || b == B)
|
||||||
stock = stock_filter(:,:,:,1:irun4-1);
|
stock = stock_filter(:,:,:,1:irun4-1);
|
||||||
ifil4 = ifil4 + 1;
|
ifil4 = ifil4 + 1;
|
||||||
save([DirectoryName '/' M_.fname '_filter' int2str(ifil4) '.mat'],'stock');
|
save([DirectoryName '/' M_.fname '_filter' int2str(ifil4) '.mat'],'stock');
|
||||||
irun4 = 1;
|
irun4 = 1;
|
||||||
end
|
end
|
||||||
|
|
||||||
if irun5 > MAX_nruns || b == B
|
if irun5 > MAX_nruns || b == B
|
||||||
stock = stock_param(1:irun5-1,:);
|
stock = stock_param(1:irun5-1,:);
|
||||||
ifil5 = ifil5 + 1;
|
ifil5 = ifil5 + 1;
|
||||||
|
|
|
@ -150,7 +150,7 @@ while fpar<npar
|
||||||
end
|
end
|
||||||
stock_param(irun2,:) = deep;
|
stock_param(irun2,:) = deep;
|
||||||
set_parameters(deep);
|
set_parameters(deep);
|
||||||
[dr,info] = resol(oo_.steady_state,0);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
if info(1)
|
if info(1)
|
||||||
nosaddle = nosaddle + 1;
|
nosaddle = nosaddle + 1;
|
||||||
fpar = fpar - 1;
|
fpar = fpar - 1;
|
||||||
|
|
|
@ -2,8 +2,8 @@ function [nvar,vartan,NumberOfConditionalDecompFiles] = ...
|
||||||
dsge_simulated_theoretical_conditional_variance_decomposition(SampleSize,Steps,M_,options_,oo_,type)
|
dsge_simulated_theoretical_conditional_variance_decomposition(SampleSize,Steps,M_,options_,oo_,type)
|
||||||
% This function computes the posterior or prior distribution of the conditional variance
|
% This function computes the posterior or prior distribution of the conditional variance
|
||||||
% decomposition of the endogenous variables (or a subset of the endogenous variables).
|
% decomposition of the endogenous variables (or a subset of the endogenous variables).
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% SampleSize [integer] scalar, number of simulations.
|
% SampleSize [integer] scalar, number of simulations.
|
||||||
% M_ [structure] Dynare structure describing the model.
|
% M_ [structure] Dynare structure describing the model.
|
||||||
% options_ [structure] Dynare structure defining global options.
|
% options_ [structure] Dynare structure defining global options.
|
||||||
|
@ -11,7 +11,7 @@ function [nvar,vartan,NumberOfConditionalDecompFiles] = ...
|
||||||
% type [string] 'prior' or 'posterior'
|
% type [string] 'prior' or 'posterior'
|
||||||
%
|
%
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% nvar [integer] nvar is the number of stationary variables.
|
% nvar [integer] nvar is the number of stationary variables.
|
||||||
% vartan [char] array of characters (with nvar rows).
|
% vartan [char] array of characters (with nvar rows).
|
||||||
% NumberOfConditionalDecompFiles [integer] scalar, number of prior or posterior data files (for covariance).
|
% NumberOfConditionalDecompFiles [integer] scalar, number of prior or posterior data files (for covariance).
|
||||||
|
@ -103,7 +103,7 @@ for file = 1:NumberOfDrawsFiles
|
||||||
dr = pdraws{linee,2};
|
dr = pdraws{linee,2};
|
||||||
else
|
else
|
||||||
set_parameters(pdraws{linee,1});
|
set_parameters(pdraws{linee,1});
|
||||||
[dr,info] = resol(oo_.steady_state,0);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
end
|
end
|
||||||
if first_call
|
if first_call
|
||||||
endo_nbr = M_.endo_nbr;
|
endo_nbr = M_.endo_nbr;
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
function [nvar,vartan,CorrFileNumber] = dsge_simulated_theoretical_correlation(SampleSize,nar,M_,options_,oo_,type)
|
function [nvar,vartan,CorrFileNumber] = dsge_simulated_theoretical_correlation(SampleSize,nar,M_,options_,oo_,type)
|
||||||
% This function computes the posterior or prior distribution of the endogenous
|
% This function computes the posterior or prior distribution of the endogenous
|
||||||
% variables second order moments.
|
% variables second order moments.
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% SampleSize [integer]
|
% SampleSize [integer]
|
||||||
% nar [integer]
|
% nar [integer]
|
||||||
% M_ [structure]
|
% M_ [structure]
|
||||||
% options_ [structure]
|
% options_ [structure]
|
||||||
% oo_ [structure]
|
% oo_ [structure]
|
||||||
% type [string]
|
% type [string]
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% nvar [integer]
|
% nvar [integer]
|
||||||
% vartan [char]
|
% vartan [char]
|
||||||
% CorrFileNumber [integer]
|
% CorrFileNumber [integer]
|
||||||
|
@ -98,7 +98,7 @@ for file = 1:NumberOfDrawsFiles
|
||||||
dr = pdraws{linee,2};
|
dr = pdraws{linee,2};
|
||||||
else
|
else
|
||||||
set_parameters(pdraws{linee,1});
|
set_parameters(pdraws{linee,1});
|
||||||
[dr,info] = resol(oo_.steady_state,0);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
end
|
end
|
||||||
tmp = th_autocovariances(dr,ivar,M_,options_,nodecomposition);
|
tmp = th_autocovariances(dr,ivar,M_,options_,nodecomposition);
|
||||||
for i=1:nar
|
for i=1:nar
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
function [nvar,vartan,CovarFileNumber] = dsge_simulated_theoretical_covariance(SampleSize,M_,options_,oo_,type)
|
function [nvar,vartan,CovarFileNumber] = dsge_simulated_theoretical_covariance(SampleSize,M_,options_,oo_,type)
|
||||||
% This function computes the posterior or prior distribution of the endogenous
|
% This function computes the posterior or prior distribution of the endogenous
|
||||||
% variables second order moments.
|
% variables second order moments.
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% SampleSize [integer] scalar, number of simulations.
|
% SampleSize [integer] scalar, number of simulations.
|
||||||
% M_ [structure] Dynare structure describing the model.
|
% M_ [structure] Dynare structure describing the model.
|
||||||
% options_ [structure] Dynare structure defining global options.
|
% options_ [structure] Dynare structure defining global options.
|
||||||
|
@ -10,7 +10,7 @@ function [nvar,vartan,CovarFileNumber] = dsge_simulated_theoretical_covariance(S
|
||||||
% type [string] 'prior' or 'posterior'
|
% type [string] 'prior' or 'posterior'
|
||||||
%
|
%
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% nvar [integer] nvar is the number of stationary variables.
|
% nvar [integer] nvar is the number of stationary variables.
|
||||||
% vartan [char] array of characters (with nvar rows).
|
% vartan [char] array of characters (with nvar rows).
|
||||||
% CovarFileNumber [integer] scalar, number of prior or posterior data files (for covariance).
|
% CovarFileNumber [integer] scalar, number of prior or posterior data files (for covariance).
|
||||||
|
@ -98,7 +98,7 @@ for file = 1:NumberOfDrawsFiles
|
||||||
dr = pdraws{linee,2};
|
dr = pdraws{linee,2};
|
||||||
else
|
else
|
||||||
set_parameters(pdraws{linee,1});
|
set_parameters(pdraws{linee,1});
|
||||||
[dr,info] = resol(oo_.steady_state,0);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
end
|
end
|
||||||
tmp = th_autocovariances(dr,ivar,M_,options_,nodecomposition);
|
tmp = th_autocovariances(dr,ivar,M_,options_,nodecomposition);
|
||||||
for i=1:nvar
|
for i=1:nvar
|
||||||
|
|
|
@ -2,8 +2,8 @@ function [nvar,vartan,NumberOfDecompFiles] = ...
|
||||||
dsge_simulated_theoretical_variance_decomposition(SampleSize,M_,options_,oo_,type)
|
dsge_simulated_theoretical_variance_decomposition(SampleSize,M_,options_,oo_,type)
|
||||||
% This function computes the posterior or prior distribution of the variance
|
% This function computes the posterior or prior distribution of the variance
|
||||||
% decomposition of the observed endogenous variables.
|
% decomposition of the observed endogenous variables.
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% SampleSize [integer] scalar, number of simulations.
|
% SampleSize [integer] scalar, number of simulations.
|
||||||
% M_ [structure] Dynare structure describing the model.
|
% M_ [structure] Dynare structure describing the model.
|
||||||
% options_ [structure] Dynare structure defining global options.
|
% options_ [structure] Dynare structure defining global options.
|
||||||
|
@ -11,7 +11,7 @@ function [nvar,vartan,NumberOfDecompFiles] = ...
|
||||||
% type [string] 'prior' or 'posterior'
|
% type [string] 'prior' or 'posterior'
|
||||||
%
|
%
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% nvar [integer] nvar is the number of stationary variables.
|
% nvar [integer] nvar is the number of stationary variables.
|
||||||
% vartan [char] array of characters (with nvar rows).
|
% vartan [char] array of characters (with nvar rows).
|
||||||
% CovarFileNumber [integer] scalar, number of prior or posterior data files (for covariance).
|
% CovarFileNumber [integer] scalar, number of prior or posterior data files (for covariance).
|
||||||
|
@ -39,7 +39,7 @@ nodecomposition = 0;
|
||||||
if strcmpi(type,'posterior')
|
if strcmpi(type,'posterior')
|
||||||
DrawsFiles = dir([M_.dname '/metropolis/' M_.fname '_' type '_draws*' ]);
|
DrawsFiles = dir([M_.dname '/metropolis/' M_.fname '_' type '_draws*' ]);
|
||||||
posterior = 1;
|
posterior = 1;
|
||||||
elseif strcmpi(type,'prior')
|
elseif strcmpi(type,'prior')
|
||||||
DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]);
|
DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]);
|
||||||
CheckPath('prior/moments');
|
CheckPath('prior/moments');
|
||||||
posterior = 0;
|
posterior = 0;
|
||||||
|
@ -66,7 +66,7 @@ nvar = length(ivar);
|
||||||
|
|
||||||
% Set the size of the auto-correlation function to zero.
|
% Set the size of the auto-correlation function to zero.
|
||||||
nar = options_.ar;
|
nar = options_.ar;
|
||||||
options_.ar = 0;
|
options_.ar = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ for file = 1:NumberOfDrawsFiles
|
||||||
dr = pdraws{linee,2};
|
dr = pdraws{linee,2};
|
||||||
else
|
else
|
||||||
set_parameters(pdraws{linee,1});
|
set_parameters(pdraws{linee,1});
|
||||||
[dr,info] = resol(oo_.steady_state,0);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
end
|
end
|
||||||
tmp = th_autocovariances(dr,ivar,M_,options_,nodecomposition);
|
tmp = th_autocovariances(dr,ivar,M_,options_,nodecomposition);
|
||||||
for i=1:nvar
|
for i=1:nvar
|
||||||
|
|
|
@ -38,9 +38,9 @@ function [A,B,ys,info] = dynare_resolve(mode)
|
||||||
% 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 oo_ M_
|
global oo_ M_ oo_
|
||||||
|
|
||||||
[oo_.dr,info] = resol(oo_.steady_state,0);
|
[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
|
|
||||||
if info(1) > 0
|
if info(1) > 0
|
||||||
A = [];
|
A = [];
|
||||||
|
|
|
@ -2,20 +2,20 @@ function [llik,parameters] = evaluate_likelihood(parameters)
|
||||||
% Evaluate the logged likelihood at parameters.
|
% Evaluate the logged likelihood at parameters.
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% o parameters a string ('posterior mode','posterior mean','posterior median','prior mode','prior mean') or a vector of values for
|
% o parameters a string ('posterior mode','posterior mean','posterior median','prior mode','prior mean') or a vector of values for
|
||||||
% the (estimated) parameters of the model.
|
% the (estimated) parameters of the model.
|
||||||
%
|
%
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% o ldens [double] value of the sample logged density at parameters.
|
% o ldens [double] value of the sample logged density at parameters.
|
||||||
% o parameters [double] vector of values for the estimated parameters.
|
% o parameters [double] vector of values for the estimated parameters.
|
||||||
%
|
%
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
% None
|
% None
|
||||||
%
|
%
|
||||||
% REMARKS
|
% REMARKS
|
||||||
% [1] This function cannot evaluate the likelihood of a dsge-var model...
|
% [1] This function cannot evaluate the likelihood of a dsge-var model...
|
||||||
% [2] This function use persistent variables for the dataset and the description of the missing observations. Consequently, if this function
|
% [2] This function use persistent variables for the dataset and the description of the missing observations. Consequently, if this function
|
||||||
% is called more than once (by changing the value of parameters) the sample *must not* change.
|
% is called more than once (by changing the value of parameters) the sample *must not* change.
|
||||||
|
|
||||||
% Copyright (C) 2009-2010 Dynare Team
|
% Copyright (C) 2009-2010 Dynare Team
|
||||||
|
@ -77,7 +77,7 @@ if isempty(load_data)
|
||||||
% Transform the data.
|
% Transform the data.
|
||||||
if options_.loglinear
|
if options_.loglinear
|
||||||
if ~options_.logdata
|
if ~options_.logdata
|
||||||
rawdata = log(rawdata);
|
rawdata = log(rawdata);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
% Test if the data set is real.
|
% Test if the data set is real.
|
||||||
|
@ -109,7 +109,7 @@ if isempty(load_data)
|
||||||
[ys,tchek] = feval([M_.fname '_steadystate'],...
|
[ys,tchek] = feval([M_.fname '_steadystate'],...
|
||||||
[zeros(M_.exo_nbr,1);...
|
[zeros(M_.exo_nbr,1);...
|
||||||
oo_.exo_det_steady_state]);
|
oo_.exo_det_steady_state]);
|
||||||
if size(ys,1) < M_.endo_nbr
|
if size(ys,1) < M_.endo_nbr
|
||||||
if length(M_.aux_vars) > 0
|
if length(M_.aux_vars) > 0
|
||||||
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
|
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
|
||||||
M_.fname,...
|
M_.fname,...
|
||||||
|
@ -123,7 +123,7 @@ if isempty(load_data)
|
||||||
end
|
end
|
||||||
oo_.steady_state = ys;
|
oo_.steady_state = ys;
|
||||||
else% if the steady state file is not provided.
|
else% if the steady state file is not provided.
|
||||||
[dd,info] = resol(oo_.steady_state,0);
|
[dd,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
oo_.steady_state = dd.ys; clear('dd');
|
oo_.steady_state = dd.ys; clear('dd');
|
||||||
end
|
end
|
||||||
if all(abs(oo_.steady_state(bayestopt_.mfys))<1e-9)
|
if all(abs(oo_.steady_state(bayestopt_.mfys))<1e-9)
|
||||||
|
|
|
@ -2,10 +2,10 @@ function oo = evaluate_smoother(parameters)
|
||||||
% Evaluate the smoother at parameters.
|
% Evaluate the smoother at parameters.
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% o parameters a string ('posterior mode','posterior mean','posterior median','prior mode','prior mean') or a vector of values for
|
% o parameters a string ('posterior mode','posterior mean','posterior median','prior mode','prior mean') or a vector of values for
|
||||||
% the (estimated) parameters of the model.
|
% the (estimated) parameters of the model.
|
||||||
%
|
%
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% o oo [structure] results:
|
% o oo [structure] results:
|
||||||
% - SmoothedVariables
|
% - SmoothedVariables
|
||||||
|
@ -16,12 +16,12 @@ function oo = evaluate_smoother(parameters)
|
||||||
% - SmoothedVariables
|
% - SmoothedVariables
|
||||||
% - SmoothedVariables
|
% - SmoothedVariables
|
||||||
% - SmoothedVariables
|
% - SmoothedVariables
|
||||||
%
|
%
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
% None
|
% None
|
||||||
%
|
%
|
||||||
% REMARKS
|
% REMARKS
|
||||||
% [1] This function use persistent variables for the dataset and the description of the missing observations. Consequently, if this function
|
% [1] This function use persistent variables for the dataset and the description of the missing observations. Consequently, if this function
|
||||||
% is called more than once (by changing the value of parameters) the sample *must not* change.
|
% is called more than once (by changing the value of parameters) the sample *must not* change.
|
||||||
|
|
||||||
% Copyright (C) 2010-2011 Dynare Team
|
% Copyright (C) 2010-2011 Dynare Team
|
||||||
|
@ -83,7 +83,7 @@ if isempty(load_data)
|
||||||
% Transform the data.
|
% Transform the data.
|
||||||
if options_.loglinear
|
if options_.loglinear
|
||||||
if ~options_.logdata
|
if ~options_.logdata
|
||||||
rawdata = log(rawdata);
|
rawdata = log(rawdata);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
% Test if the data set is real.
|
% Test if the data set is real.
|
||||||
|
@ -115,7 +115,7 @@ if isempty(load_data)
|
||||||
[ys,tchek] = feval([M_.fname '_steadystate'],...
|
[ys,tchek] = feval([M_.fname '_steadystate'],...
|
||||||
[zeros(M_.exo_nbr,1);...
|
[zeros(M_.exo_nbr,1);...
|
||||||
oo_.exo_det_steady_state]);
|
oo_.exo_det_steady_state]);
|
||||||
if size(ys,1) < M_.endo_nbr
|
if size(ys,1) < M_.endo_nbr
|
||||||
if length(M_.aux_vars) > 0
|
if length(M_.aux_vars) > 0
|
||||||
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
|
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
|
||||||
M_.fname,...
|
M_.fname,...
|
||||||
|
@ -129,7 +129,7 @@ if isempty(load_data)
|
||||||
end
|
end
|
||||||
oo_.steady_state = ys;
|
oo_.steady_state = ys;
|
||||||
else% if the steady state file is not provided.
|
else% if the steady state file is not provided.
|
||||||
[dd,info] = resol(oo_.steady_state,0);
|
[dd,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
oo_.steady_state = dd.ys; clear('dd');
|
oo_.steady_state = dd.ys; clear('dd');
|
||||||
end
|
end
|
||||||
if all(abs(oo_.steady_state(bayestopt_.mfys))<1e-9)
|
if all(abs(oo_.steady_state(bayestopt_.mfys))<1e-9)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
function time_series = extended_path(initial_conditions,sample_size,init)
|
function time_series = extended_path(initial_conditions,sample_size,init)
|
||||||
% Stochastic simulation of a non linear DSGE model using the Extended Path method (Fair and Taylor 1983). A time
|
% Stochastic simulation of a non linear DSGE model using the Extended Path method (Fair and Taylor 1983). A time
|
||||||
% series of size T is obtained by solving T perfect foresight models.
|
% series of size T is obtained by solving T perfect foresight models.
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% o initial_conditions [double] m*nlags array, where m is the number of endogenous variables in the model and
|
% o initial_conditions [double] m*nlags array, where m is the number of endogenous variables in the model and
|
||||||
% nlags is the maximum number of lags.
|
% nlags is the maximum number of lags.
|
||||||
|
@ -9,13 +9,13 @@ function time_series = extended_path(initial_conditions,sample_size,init)
|
||||||
% o init [integer] scalar, method of initialization of the perfect foresight equilibrium paths
|
% o init [integer] scalar, method of initialization of the perfect foresight equilibrium paths
|
||||||
% init=0 previous solution is used,
|
% init=0 previous solution is used,
|
||||||
% init=1 a path generated with the first order reduced form is used.
|
% init=1 a path generated with the first order reduced form is used.
|
||||||
% init=2 mix of cases 0 and 1.
|
% init=2 mix of cases 0 and 1.
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% o time_series [double] m*sample_size array, the simulations.
|
% o time_series [double] m*sample_size array, the simulations.
|
||||||
%
|
%
|
||||||
% ALGORITHM
|
% ALGORITHM
|
||||||
%
|
%
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
|
|
||||||
% Copyright (C) 2009-2010 Dynare Team
|
% Copyright (C) 2009-2010 Dynare Team
|
||||||
|
@ -34,11 +34,11 @@ function time_series = extended_path(initial_conditions,sample_size,init)
|
||||||
%
|
%
|
||||||
% 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 M_ oo_ options_
|
global M_ oo_ options_
|
||||||
|
|
||||||
% Set default initial conditions.
|
% Set default initial conditions.
|
||||||
if isempty(initial_conditions)
|
if isempty(initial_conditions)
|
||||||
initial_conditions = repmat(oo_.steady_state,1,M_.maximum_lag);
|
initial_conditions = repmat(oo_.steady_state,1,M_.maximum_lag);
|
||||||
end
|
end
|
||||||
|
|
||||||
% Set default value for the last input argument
|
% Set default value for the last input argument
|
||||||
|
@ -50,7 +50,7 @@ end
|
||||||
%options_.periods = 40;
|
%options_.periods = 40;
|
||||||
|
|
||||||
% Initialize the exogenous variables.
|
% Initialize the exogenous variables.
|
||||||
make_ex_;
|
make_ex_;
|
||||||
|
|
||||||
% Initialize the endogenous variables.
|
% Initialize the endogenous variables.
|
||||||
make_y_;
|
make_y_;
|
||||||
|
@ -59,7 +59,7 @@ make_y_;
|
||||||
if init
|
if init
|
||||||
oldopt = options_;
|
oldopt = options_;
|
||||||
options_.order = 1;
|
options_.order = 1;
|
||||||
[dr,info]=resol(oo_.steady_state,0);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
oo_.dr = dr;
|
oo_.dr = dr;
|
||||||
options_ = oldopt;
|
options_ = oldopt;
|
||||||
if init==2
|
if init==2
|
||||||
|
@ -68,16 +68,16 @@ if init
|
||||||
end
|
end
|
||||||
|
|
||||||
% Initialize the output array.
|
% Initialize the output array.
|
||||||
time_series = NaN(M_.endo_nbr,sample_size+1);
|
time_series = NaN(M_.endo_nbr,sample_size+1);
|
||||||
|
|
||||||
% Set the covariance matrix of the structural innovations.
|
% Set the covariance matrix of the structural innovations.
|
||||||
variances = diag(M_.Sigma_e);
|
variances = diag(M_.Sigma_e);
|
||||||
positive_var_indx = find(variances>0);
|
positive_var_indx = find(variances>0);
|
||||||
covariance_matrix = M_.Sigma_e(positive_var_indx,positive_var_indx);
|
covariance_matrix = M_.Sigma_e(positive_var_indx,positive_var_indx);
|
||||||
number_of_structural_innovations = length(covariance_matrix);
|
number_of_structural_innovations = length(covariance_matrix);
|
||||||
covariance_matrix_upper_cholesky = chol(covariance_matrix);
|
covariance_matrix_upper_cholesky = chol(covariance_matrix);
|
||||||
|
|
||||||
tdx = M_.maximum_lag+1;
|
tdx = M_.maximum_lag+1;
|
||||||
norme = 0;
|
norme = 0;
|
||||||
|
|
||||||
% Set verbose option
|
% Set verbose option
|
||||||
|
@ -106,7 +106,7 @@ while (t<=sample_size)
|
||||||
if init==1
|
if init==1
|
||||||
oo_.endo_simul = initial_path(:,1:end-1);
|
oo_.endo_simul = initial_path(:,1:end-1);
|
||||||
else
|
else
|
||||||
oo_.endo_simul = initial_path(:,1:end-1)*lambda + oo_.endo_simul*(1-lambda);
|
oo_.endo_simul = initial_path(:,1:end-1)*lambda + oo_.endo_simul*(1-lambda);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if init
|
if init
|
||||||
|
@ -141,7 +141,7 @@ while (t<=sample_size)
|
||||||
if new_draw
|
if new_draw
|
||||||
info.time = info.time+time;
|
info.time = info.time+time;
|
||||||
time_series(:,t+1) = oo_.endo_simul(:,tdx);
|
time_series(:,t+1) = oo_.endo_simul(:,tdx);
|
||||||
oo_.endo_simul(:,1:end-1) = oo_.endo_simul(:,2:end);
|
oo_.endo_simul(:,1:end-1) = oo_.endo_simul(:,2:end);
|
||||||
oo_.endo_simul(:,end) = oo_.steady_state;
|
oo_.endo_simul(:,end) = oo_.steady_state;
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -71,7 +71,7 @@ for i=1:replic
|
||||||
params = rndprior(bayestopt_);
|
params = rndprior(bayestopt_);
|
||||||
set_parameters(params);
|
set_parameters(params);
|
||||||
% solve the model
|
% solve the model
|
||||||
[dr,info] = resol(oo_.steady_state,0);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
% discard problematic cases
|
% discard problematic cases
|
||||||
if info
|
if info
|
||||||
continue
|
continue
|
||||||
|
@ -123,7 +123,7 @@ end
|
||||||
|
|
||||||
% compute shock uncertainty around forecast with mean prior
|
% compute shock uncertainty around forecast with mean prior
|
||||||
set_parameters(bayestopt_.p1);
|
set_parameters(bayestopt_.p1);
|
||||||
[dr,info] = resol(oo_.steady_state,0);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
[yf3,yf3_intv] = forcst(dr,y0,periods,var_list);
|
[yf3,yf3_intv] = forcst(dr,y0,periods,var_list);
|
||||||
yf3_1 = yf3'-[zeros(maximum_lag,n); yf3_intv];
|
yf3_1 = yf3'-[zeros(maximum_lag,n); yf3_intv];
|
||||||
yf3_2 = yf3'+[zeros(maximum_lag,n); yf3_intv];
|
yf3_2 = yf3'+[zeros(maximum_lag,n); yf3_intv];
|
||||||
|
@ -147,7 +147,7 @@ dynare_graph_close;
|
||||||
|
|
||||||
% saving results
|
% saving results
|
||||||
save_results(yf_mean,'oo_.forecast.mean.',var_list);
|
save_results(yf_mean,'oo_.forecast.mean.',var_list);
|
||||||
save_results(yf1(:,:,k1(1)),'oo_.forecast.HPDinf.',var_list);
|
save_results(yf1(:,:,k1(1)),'oo_.forecast.HPDinf.',var_list);
|
||||||
save_results(yf1(:,:,k1(2)),'oo_.forecast.HPDsup.',var_list);
|
save_results(yf1(:,:,k1(2)),'oo_.forecast.HPDsup.',var_list);
|
||||||
save_results(yf2(:,:,k2(1)),'oo_.forecast.HPDTotalinf.',var_list);
|
save_results(yf2(:,:,k2(1)),'oo_.forecast.HPDTotalinf.',var_list);
|
||||||
save_results(yf2(:,:,k2(2)),'oo_.forecast.HPDTotalsup.',var_list);
|
save_results(yf2(:,:,k2(2)),'oo_.forecast.HPDTotalsup.',var_list);
|
|
@ -9,10 +9,10 @@ function dynare_MC(var_list_,OutDir,data,rawdata,data_info)
|
||||||
% Written by Marco Ratto, 2006
|
% Written by Marco Ratto, 2006
|
||||||
% Joint Research Centre, The European Commission,
|
% Joint Research Centre, The European Commission,
|
||||||
% (http://eemc.jrc.ec.europa.eu/),
|
% (http://eemc.jrc.ec.europa.eu/),
|
||||||
% marco.ratto@jrc.it
|
% marco.ratto@jrc.it
|
||||||
%
|
%
|
||||||
% Disclaimer: This software is not subject to copyright protection and is in the public domain.
|
% Disclaimer: This software is not subject to copyright protection and is in the public domain.
|
||||||
% It is an experimental system. The Joint Research Centre of European Commission
|
% It is an experimental system. The Joint Research Centre of European Commission
|
||||||
% assumes no responsibility whatsoever for its use by other parties
|
% assumes no responsibility whatsoever for its use by other parties
|
||||||
% and makes no guarantees, expressed or implied, about its quality, reliability, or any other
|
% and makes no guarantees, expressed or implied, about its quality, reliability, or any other
|
||||||
% characteristic. We would appreciate acknowledgement if the software is used.
|
% characteristic. We would appreciate acknowledgement if the software is used.
|
||||||
|
@ -20,7 +20,7 @@ function dynare_MC(var_list_,OutDir,data,rawdata,data_info)
|
||||||
% M. Ratto, Global Sensitivity Analysis for Macroeconomic models, MIMEO, 2006.
|
% M. Ratto, Global Sensitivity Analysis for Macroeconomic models, MIMEO, 2006.
|
||||||
%
|
%
|
||||||
|
|
||||||
global M_ options_ oo_ estim_params_
|
global M_ options_ oo_ estim_params_
|
||||||
global bayestopt_
|
global bayestopt_
|
||||||
|
|
||||||
% if options_.filtered_vars ~= 0 & options_.filter_step_ahead == 0
|
% if options_.filtered_vars ~= 0 & options_.filter_step_ahead == 0
|
||||||
|
@ -31,7 +31,7 @@ global bayestopt_
|
||||||
% else
|
% else
|
||||||
% options_.nk = 0;
|
% options_.nk = 0;
|
||||||
% end
|
% end
|
||||||
%
|
%
|
||||||
options_.filter_step_ahead=1;
|
options_.filter_step_ahead=1;
|
||||||
options_.nk = 1;
|
options_.nk = 1;
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ for b=1:B
|
||||||
ib=ib+1;
|
ib=ib+1;
|
||||||
deep = x(b,:)';
|
deep = x(b,:)';
|
||||||
set_all_parameters(deep);
|
set_all_parameters(deep);
|
||||||
dr = resol(oo_.steady_state,0);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
%deep(1:offset) = xparam1(1:offset);
|
%deep(1:offset) = xparam1(1:offset);
|
||||||
logpo2(b,1) = DsgeLikelihood(deep,gend,data,data_index,number_of_observations,no_more_missing_observations);
|
logpo2(b,1) = DsgeLikelihood(deep,gend,data,data_index,number_of_observations,no_more_missing_observations);
|
||||||
if opt_gsa.lik_only==0,
|
if opt_gsa.lik_only==0,
|
||||||
|
@ -115,7 +115,7 @@ for b=1:B
|
||||||
stock_filter = zeros(M_.endo_nbr,gend+1,40);
|
stock_filter = zeros(M_.endo_nbr,gend+1,40);
|
||||||
stock_ys = zeros(40, M_.endo_nbr);
|
stock_ys = zeros(40, M_.endo_nbr);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
waitbar(b/B,h,['MC smoother ...',num2str(b),'/',num2str(B)]);
|
waitbar(b/B,h,['MC smoother ...',num2str(b),'/',num2str(B)]);
|
||||||
end
|
end
|
||||||
close(h)
|
close(h)
|
||||||
|
|
|
@ -101,12 +101,12 @@ if fload==0,
|
||||||
% if prepSA
|
% if prepSA
|
||||||
% T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),Nsam/2);
|
% T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),Nsam/2);
|
||||||
% end
|
% end
|
||||||
|
|
||||||
if isfield(dr_,'ghx'),
|
if isfield(dr_,'ghx'),
|
||||||
egg=zeros(length(dr_.eigval),Nsam);
|
egg=zeros(length(dr_.eigval),Nsam);
|
||||||
end
|
end
|
||||||
yys=zeros(length(dr_.ys),Nsam);
|
yys=zeros(length(dr_.ys),Nsam);
|
||||||
|
|
||||||
if opt_gsa.morris == 1
|
if opt_gsa.morris == 1
|
||||||
[lpmat, OutFact] = Sampling_Function_2(nliv, np+nshock, ntra, ones(np+nshock, 1), zeros(np+nshock,1), []);
|
[lpmat, OutFact] = Sampling_Function_2(nliv, np+nshock, ntra, ones(np+nshock, 1), zeros(np+nshock,1), []);
|
||||||
lpmat = lpmat.*(nliv-1)/nliv+1/nliv/2;
|
lpmat = lpmat.*(nliv-1)/nliv+1/nliv/2;
|
||||||
|
@ -129,7 +129,7 @@ if fload==0,
|
||||||
for j=1:np,
|
for j=1:np,
|
||||||
lpmat(:,j) = randperm(Nsam)'./(Nsam+1); %latin hypercube
|
lpmat(:,j) = randperm(Nsam)'./(Nsam+1); %latin hypercube
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
% try
|
% try
|
||||||
|
@ -220,7 +220,7 @@ if fload==0,
|
||||||
ub=min([bayestopt_.ub(j+nshock) xparam1(j+nshock)*(1+neighborhood_width)]);
|
ub=min([bayestopt_.ub(j+nshock) xparam1(j+nshock)*(1+neighborhood_width)]);
|
||||||
lb=max([bayestopt_.lb(j+nshock) xparam1(j+nshock)*(1-neighborhood_width)]);
|
lb=max([bayestopt_.lb(j+nshock) xparam1(j+nshock)*(1-neighborhood_width)]);
|
||||||
lpmat(:,j)=lpmat(:,j).*(ub-lb)+lb;
|
lpmat(:,j)=lpmat(:,j).*(ub-lb)+lb;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
d = chol(inv(hh));
|
d = chol(inv(hh));
|
||||||
lp=randn(Nsam*2,nshock+np)*d+kron(ones(Nsam*2,1),xparam1');
|
lp=randn(Nsam*2,nshock+np)*d+kron(ones(Nsam*2,1),xparam1');
|
||||||
|
@ -318,7 +318,7 @@ if fload==0,
|
||||||
iunstable=iunstable(find(iunstable)); % unstable params
|
iunstable=iunstable(find(iunstable)); % unstable params
|
||||||
iindeterm=iindeterm(find(iindeterm)); % indeterminacy
|
iindeterm=iindeterm(find(iindeterm)); % indeterminacy
|
||||||
iwrong=iwrong(find(iwrong)); % dynare could not find solution
|
iwrong=iwrong(find(iwrong)); % dynare could not find solution
|
||||||
|
|
||||||
% % map stable samples
|
% % map stable samples
|
||||||
% istable=[1:Nsam];
|
% istable=[1:Nsam];
|
||||||
% for j=1:Nsam,
|
% for j=1:Nsam,
|
||||||
|
@ -368,7 +368,7 @@ if fload==0,
|
||||||
'bkpprior','lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ...
|
'bkpprior','lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ...
|
||||||
'egg','yys','T','nspred','nboth','nfwrd')
|
'egg','yys','T','nspred','nboth','nfwrd')
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
if ~prepSA
|
if ~prepSA
|
||||||
save([OutputDirectoryName '/' fname_ '_mc'], ...
|
save([OutputDirectoryName '/' fname_ '_mc'], ...
|
||||||
|
@ -388,8 +388,8 @@ else
|
||||||
end
|
end
|
||||||
load(filetoload,'lpmat','lpmat0','iunstable','istable','iindeterm','iwrong','egg','yys','nspred','nboth','nfwrd')
|
load(filetoload,'lpmat','lpmat0','iunstable','istable','iindeterm','iwrong','egg','yys','nspred','nboth','nfwrd')
|
||||||
Nsam = size(lpmat,1);
|
Nsam = size(lpmat,1);
|
||||||
|
|
||||||
|
|
||||||
if prepSA & isempty(strmatch('T',who('-file', filetoload),'exact')),
|
if prepSA & isempty(strmatch('T',who('-file', filetoload),'exact')),
|
||||||
h = waitbar(0,'Please wait...');
|
h = waitbar(0,'Please wait...');
|
||||||
options_.periods=0;
|
options_.periods=0;
|
||||||
|
@ -486,7 +486,7 @@ if length(iunstable)>0 & length(iunstable)<Nsam,
|
||||||
stab_map_1(lpmat, [1:Nsam], iindeterm, [aname, '_indet'], 1, indindet, OutputDirectoryName);
|
stab_map_1(lpmat, [1:Nsam], iindeterm, [aname, '_indet'], 1, indindet, OutputDirectoryName);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ~isempty(ixun),
|
if ~isempty(ixun),
|
||||||
[proba, dproba] = stab_map_1(lpmat, [1:Nsam], ixun, [aname, '_unst'],0);
|
[proba, dproba] = stab_map_1(lpmat, [1:Nsam], ixun, [aname, '_unst'],0);
|
||||||
% indunst=find(dproba>ksstat);
|
% indunst=find(dproba>ksstat);
|
||||||
|
@ -500,7 +500,7 @@ if length(iunstable)>0 & length(iunstable)<Nsam,
|
||||||
stab_map_1(lpmat, [1:Nsam], ixun, [aname, '_unst'], 1, indunst, OutputDirectoryName);
|
stab_map_1(lpmat, [1:Nsam], ixun, [aname, '_unst'], 1, indunst, OutputDirectoryName);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ~isempty(iwrong),
|
if ~isempty(iwrong),
|
||||||
[proba, dproba] = stab_map_1(lpmat, [1:Nsam], iwrong, [aname, '_wrong'],0);
|
[proba, dproba] = stab_map_1(lpmat, [1:Nsam], iwrong, [aname, '_wrong'],0);
|
||||||
% indwrong=find(dproba>ksstat);
|
% indwrong=find(dproba>ksstat);
|
||||||
|
@ -514,13 +514,13 @@ if length(iunstable)>0 & length(iunstable)<Nsam,
|
||||||
stab_map_1(lpmat, [1:Nsam], iwrong, [aname, '_wrong'], 1, indwrong, OutputDirectoryName);
|
stab_map_1(lpmat, [1:Nsam], iwrong, [aname, '_wrong'], 1, indwrong, OutputDirectoryName);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
disp(' ')
|
disp(' ')
|
||||||
disp('Starting bivariate analysis:')
|
disp('Starting bivariate analysis:')
|
||||||
|
|
||||||
c0=corrcoef(lpmat(istable,:));
|
c0=corrcoef(lpmat(istable,:));
|
||||||
c00=tril(c0,-1);
|
c00=tril(c0,-1);
|
||||||
|
|
||||||
stab_map_2(lpmat(istable,:),alpha2, pvalue_corr, asname, OutputDirectoryName);
|
stab_map_2(lpmat(istable,:),alpha2, pvalue_corr, asname, OutputDirectoryName);
|
||||||
if length(iunstable)>10,
|
if length(iunstable)>10,
|
||||||
stab_map_2(lpmat(iunstable,:),alpha2, pvalue_corr, auname, OutputDirectoryName);
|
stab_map_2(lpmat(iunstable,:),alpha2, pvalue_corr, auname, OutputDirectoryName);
|
||||||
|
@ -534,12 +534,12 @@ if length(iunstable)>0 & length(iunstable)<Nsam,
|
||||||
if length(iwrong)>10,
|
if length(iwrong)>10,
|
||||||
stab_map_2(lpmat(iwrong,:),alpha2, pvalue_corr, awrongname, OutputDirectoryName);
|
stab_map_2(lpmat(iwrong,:),alpha2, pvalue_corr, awrongname, OutputDirectoryName);
|
||||||
end
|
end
|
||||||
|
|
||||||
x0=0.5.*(bayestopt_.ub(1:nshock)-bayestopt_.lb(1:nshock))+bayestopt_.lb(1:nshock);
|
x0=0.5.*(bayestopt_.ub(1:nshock)-bayestopt_.lb(1:nshock))+bayestopt_.lb(1:nshock);
|
||||||
x0 = [x0; lpmat(istable(1),:)'];
|
x0 = [x0; lpmat(istable(1),:)'];
|
||||||
if istable(end)~=Nsam
|
if istable(end)~=Nsam
|
||||||
M_.params(estim_params_.param_vals(:,1)) = lpmat(istable(1),:)';
|
M_.params(estim_params_.param_vals(:,1)) = lpmat(istable(1),:)';
|
||||||
[oo_.dr, info] = resol(oo_.steady_state,0);
|
[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
% stoch_simul([]);
|
% stoch_simul([]);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -551,7 +551,7 @@ else
|
||||||
disp('All parameter values in the specified ranges are not acceptable!')
|
disp('All parameter values in the specified ranges are not acceptable!')
|
||||||
x0=[];
|
x0=[];
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ dr = set_state_space(oo_.dr,M_);
|
||||||
if exist([M_.fname '_steadystate'])
|
if exist([M_.fname '_steadystate'])
|
||||||
[ys,check1] = feval([M_.fname '_steadystate'],oo_.steady_state,...
|
[ys,check1] = feval([M_.fname '_steadystate'],oo_.steady_state,...
|
||||||
[oo_.exo_steady_state; oo_.exo_det_steady_state]);
|
[oo_.exo_steady_state; oo_.exo_det_steady_state]);
|
||||||
if size(ys,1) < M_.endo_nbr
|
if size(ys,1) < M_.endo_nbr
|
||||||
if length(M_.aux_vars) > 0
|
if length(M_.aux_vars) > 0
|
||||||
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
|
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
|
||||||
M_.fname,...
|
M_.fname,...
|
||||||
|
@ -114,6 +114,6 @@ for i=1:np
|
||||||
end
|
end
|
||||||
disp(sprintf('Objective function : %16.6g\n',f));
|
disp(sprintf('Objective function : %16.6g\n',f));
|
||||||
disp(' ')
|
disp(' ')
|
||||||
oo_.dr=resol(oo_.steady_state,0);
|
[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
|
|
||||||
% 05/10/03 MJ modified to work with osr.m and give full report
|
% 05/10/03 MJ modified to work with osr.m and give full report
|
|
@ -18,7 +18,7 @@ function [loss,vx,info]=osr_obj(x,i_params,i_var,weights);
|
||||||
% 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 M_ oo_ optimal_Q_ it_
|
global M_ oo_ options_ optimal_Q_ it_
|
||||||
% global ys_ Sigma_e_ endo_nbr exo_nbr optimal_Q_ it_ ykmin_ options_
|
% global ys_ Sigma_e_ endo_nbr exo_nbr optimal_Q_ it_ ykmin_ options_
|
||||||
|
|
||||||
vx = [];
|
vx = [];
|
||||||
|
@ -27,7 +27,7 @@ M_.params(i_params) = x;
|
||||||
|
|
||||||
% don't change below until the part where the loss function is computed
|
% don't change below until the part where the loss function is computed
|
||||||
it_ = M_.maximum_lag+1;
|
it_ = M_.maximum_lag+1;
|
||||||
[dr,info] = resol(oo_.steady_state,0);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
|
|
||||||
switch info(1)
|
switch info(1)
|
||||||
case 1
|
case 1
|
||||||
|
@ -54,7 +54,7 @@ switch info(1)
|
||||||
otherwise
|
otherwise
|
||||||
end
|
end
|
||||||
|
|
||||||
vx = get_variance_of_endogenous_variables(dr,i_var);
|
vx = get_variance_of_endogenous_variables(dr,i_var);
|
||||||
loss = weights(:)'*vx(:);
|
loss = weights(:)'*vx(:);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ function info = perfect_foresight_simulation(compute_linear_solution,steady_stat
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% endo_simul [double] n*T matrix, where n is the number of endogenous variables.
|
% endo_simul [double] n*T matrix, where n is the number of endogenous variables.
|
||||||
% exo_simul [double] q*T matrix, where q is the number of shocks.
|
% exo_simul [double] q*T matrix, where q is the number of shocks.
|
||||||
% compute_linear_solution [integer] scalar equal to zero or one.
|
% compute_linear_solution [integer] scalar equal to zero or one.
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% none
|
% none
|
||||||
%
|
%
|
||||||
|
@ -40,19 +40,19 @@ global M_ options_ it_ oo_
|
||||||
persistent lead_lag_incidence dynamic_model ny nyp nyf nrs nrc iyf iyp isp is isf isf1 iz icf ghx iflag
|
persistent lead_lag_incidence dynamic_model ny nyp nyf nrs nrc iyf iyp isp is isf isf1 iz icf ghx iflag
|
||||||
|
|
||||||
if ~nargin && isempty(iflag)% Initialization of the persistent variables.
|
if ~nargin && isempty(iflag)% Initialization of the persistent variables.
|
||||||
lead_lag_incidence = M_.lead_lag_incidence;
|
lead_lag_incidence = M_.lead_lag_incidence;
|
||||||
dynamic_model = [M_.fname '_dynamic'];
|
dynamic_model = [M_.fname '_dynamic'];
|
||||||
ny = size(oo_.endo_simul,1);
|
ny = size(oo_.endo_simul,1);
|
||||||
nyp = nnz(lead_lag_incidence(1,:));% number of lagged variables.
|
nyp = nnz(lead_lag_incidence(1,:));% number of lagged variables.
|
||||||
nyf = nnz(lead_lag_incidence(3,:));% number of leaded variables.
|
nyf = nnz(lead_lag_incidence(3,:));% number of leaded variables.
|
||||||
nrs = ny+nyp+nyf+1;
|
nrs = ny+nyp+nyf+1;
|
||||||
nrc = nyf+1;
|
nrc = nyf+1;
|
||||||
iyf = find(lead_lag_incidence(3,:)>0);% indices for leaded variables.
|
iyf = find(lead_lag_incidence(3,:)>0);% indices for leaded variables.
|
||||||
iyp = find(lead_lag_incidence(1,:)>0);% indices for lagged variables.
|
iyp = find(lead_lag_incidence(1,:)>0);% indices for lagged variables.
|
||||||
isp = 1:nyp;
|
isp = 1:nyp;
|
||||||
is = (nyp+1):(nyp+ny); % Indices for contemporaneaous variables.
|
is = (nyp+1):(nyp+ny); % Indices for contemporaneaous variables.
|
||||||
isf = iyf+nyp;
|
isf = iyf+nyp;
|
||||||
isf1 = (nyp+ny+1):(nyf+nyp+ny+1);
|
isf1 = (nyp+ny+1):(nyf+nyp+ny+1);
|
||||||
iz = 1:(ny+nyp+nyf);
|
iz = 1:(ny+nyp+nyf);
|
||||||
icf = 1:size(iyf,2);
|
icf = 1:size(iyf,2);
|
||||||
info = [];
|
info = [];
|
||||||
|
@ -73,8 +73,8 @@ else
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if ~isstruct(compute_linear_solution) && compute_linear_solution
|
if ~isstruct(compute_linear_solution) && compute_linear_solution
|
||||||
[dr,info]=resol(steady_state,0);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
elseif isstruct(compute_linear_solution)
|
elseif isstruct(compute_linear_solution)
|
||||||
dr = compute_linear_solution;
|
dr = compute_linear_solution;
|
||||||
compute_linear_solution = 1;
|
compute_linear_solution = 1;
|
||||||
|
@ -85,22 +85,22 @@ if compute_linear_solution
|
||||||
ghx = ghx(iyf,:);
|
ghx = ghx(iyf,:);
|
||||||
end
|
end
|
||||||
|
|
||||||
periods = options_.periods;
|
periods = options_.periods;
|
||||||
|
|
||||||
stop = 0 ;
|
stop = 0 ;
|
||||||
it_init = M_.maximum_lag+1;
|
it_init = M_.maximum_lag+1;
|
||||||
|
|
||||||
info.convergence = 1;
|
info.convergence = 1;
|
||||||
info.time = 0;
|
info.time = 0;
|
||||||
info.error = 0;
|
info.error = 0;
|
||||||
info.iterations.time = zeros(options_.maxit_,1);
|
info.iterations.time = zeros(options_.maxit_,1);
|
||||||
info.iterations.error = info.iterations.time;
|
info.iterations.error = info.iterations.time;
|
||||||
|
|
||||||
last_line = options_.maxit_;
|
last_line = options_.maxit_;
|
||||||
error_growth = 0;
|
error_growth = 0;
|
||||||
|
|
||||||
h1 = clock;
|
h1 = clock;
|
||||||
for iter = 1:options_.maxit_
|
for iter = 1:options_.maxit_
|
||||||
h2 = clock;
|
h2 = clock;
|
||||||
if options_.terminal_condition
|
if options_.terminal_condition
|
||||||
c = zeros(ny*(periods+1),nrc);
|
c = zeros(ny*(periods+1),nrc);
|
||||||
|
@ -108,23 +108,23 @@ for iter = 1:options_.maxit_
|
||||||
c = zeros(ny*periods,nrc);
|
c = zeros(ny*periods,nrc);
|
||||||
end
|
end
|
||||||
it_ = it_init;
|
it_ = it_init;
|
||||||
z = [ oo_.endo_simul(iyp,it_-1) ; oo_.endo_simul(:,it_) ; oo_.endo_simul(iyf,it_+1) ];
|
z = [ oo_.endo_simul(iyp,it_-1) ; oo_.endo_simul(:,it_) ; oo_.endo_simul(iyf,it_+1) ];
|
||||||
[d1,jacobian] = feval(dynamic_model,z,oo_.exo_simul, M_.params, it_);
|
[d1,jacobian] = feval(dynamic_model,z,oo_.exo_simul, M_.params, it_);
|
||||||
jacobian = [jacobian(:,iz) , -d1];
|
jacobian = [jacobian(:,iz) , -d1];
|
||||||
ic = 1:ny;
|
ic = 1:ny;
|
||||||
icp = iyp;
|
icp = iyp;
|
||||||
c(ic,:) = jacobian(:,is)\jacobian(:,isf1) ;
|
c(ic,:) = jacobian(:,is)\jacobian(:,isf1) ;
|
||||||
for it_ = it_init+(1:periods-1-(options_.terminal_condition==2))
|
for it_ = it_init+(1:periods-1-(options_.terminal_condition==2))
|
||||||
z = [ oo_.endo_simul(iyp,it_-1) ; oo_.endo_simul(:,it_) ; oo_.endo_simul(iyf,it_+1)];
|
z = [ oo_.endo_simul(iyp,it_-1) ; oo_.endo_simul(:,it_) ; oo_.endo_simul(iyf,it_+1)];
|
||||||
[d1,jacobian] = feval(dynamic_model,z,oo_.exo_simul, M_.params, it_);
|
[d1,jacobian] = feval(dynamic_model,z,oo_.exo_simul, M_.params, it_);
|
||||||
jacobian = [jacobian(:,iz) , -d1];
|
jacobian = [jacobian(:,iz) , -d1];
|
||||||
jacobian(:,[isf nrs]) = jacobian(:,[isf nrs])-jacobian(:,isp)*c(icp,:);
|
jacobian(:,[isf nrs]) = jacobian(:,[isf nrs])-jacobian(:,isp)*c(icp,:);
|
||||||
ic = ic + ny;
|
ic = ic + ny;
|
||||||
icp = icp + ny;
|
icp = icp + ny;
|
||||||
c(ic,:) = jacobian(:,is)\jacobian(:,isf1);
|
c(ic,:) = jacobian(:,is)\jacobian(:,isf1);
|
||||||
end
|
end
|
||||||
if options_.terminal_condition
|
if options_.terminal_condition
|
||||||
if options_.terminal_condition==1% Terminal condition is Y_{T} = Y_{T+1}
|
if options_.terminal_condition==1% Terminal condition is Y_{T} = Y_{T+1}
|
||||||
s = eye(ny);
|
s = eye(ny);
|
||||||
s(:,isf) = s(:,isf)+c(ic,1:nyf);
|
s(:,isf) = s(:,isf)+c(ic,1:nyf);
|
||||||
ic = ic + ny;
|
ic = ic + ny;
|
||||||
|
@ -147,10 +147,10 @@ for iter = 1:options_.maxit_
|
||||||
else% Terminal condition is Y_{T}=Y^{\star}
|
else% Terminal condition is Y_{T}=Y^{\star}
|
||||||
c = bksup0(c,ny,nrc,iyf,icf,periods);
|
c = bksup0(c,ny,nrc,iyf,icf,periods);
|
||||||
c = reshape(c,ny,periods);
|
c = reshape(c,ny,periods);
|
||||||
oo_.endo_simul(:,it_init+(0:periods-1)) = oo_.endo_simul(:,it_init+(0:periods-1))+options_.slowc*c;
|
oo_.endo_simul(:,it_init+(0:periods-1)) = oo_.endo_simul(:,it_init+(0:periods-1))+options_.slowc*c;
|
||||||
end
|
end
|
||||||
err = max(max(abs(c)));
|
err = max(max(abs(c)));
|
||||||
info.iterations.time(iter) = etime(clock,h2);
|
info.iterations.time(iter) = etime(clock,h2);
|
||||||
info.iterations.error(iter) = err;
|
info.iterations.error(iter) = err;
|
||||||
if iter>1
|
if iter>1
|
||||||
error_growth = error_growth + (info.iterations.error(iter)>info.iterations.error(iter-1));
|
error_growth = error_growth + (info.iterations.error(iter)>info.iterations.error(iter-1));
|
||||||
|
@ -161,16 +161,16 @@ for iter = 1:options_.maxit_
|
||||||
end
|
end
|
||||||
if err < options_.dynatol
|
if err < options_.dynatol
|
||||||
stop = 1;
|
stop = 1;
|
||||||
info.time = etime(clock,h1);
|
info.time = etime(clock,h1);
|
||||||
info.error = err;
|
info.error = err;
|
||||||
info.iterations.time = info.iterations.time(1:iter);
|
info.iterations.time = info.iterations.time(1:iter);
|
||||||
info.iterations.error = info.iterations.error(1:iter);
|
info.iterations.error = info.iterations.error(1:iter);
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if stop && options_.terminal_condition==2
|
if stop && options_.terminal_condition==2
|
||||||
% Compute the distance to the deterministic steady state (for the subset of endogenous variables with a non zero
|
% Compute the distance to the deterministic steady state (for the subset of endogenous variables with a non zero
|
||||||
% steady state) at the last perdiod.
|
% steady state) at the last perdiod.
|
||||||
idx = find(abs(oo_.steady_state)>0);
|
idx = find(abs(oo_.steady_state)>0);
|
||||||
distance_to_steady_state = abs(((oo_.endo_simul(idx,end)-oo_.steady_state(idx))./oo_.steady_state(idx)))*100;
|
distance_to_steady_state = abs(((oo_.endo_simul(idx,end)-oo_.steady_state(idx))./oo_.steady_state(idx)))*100;
|
||||||
|
|
|
@ -162,7 +162,7 @@ for b=fpar:B
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
set_all_parameters(deep);
|
set_all_parameters(deep);
|
||||||
[dr,info] = resol(oo_.steady_state,0);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
|
|
||||||
if run_smoother
|
if run_smoother
|
||||||
[alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK] = ...
|
[alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK] = ...
|
||||||
|
|
|
@ -2,13 +2,13 @@ function results = prior_sampler(drsave,M_,bayestopt_,options_,oo_)
|
||||||
% This function builds a (big) prior sample.
|
% This function builds a (big) prior sample.
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% drsave [integer] Scalar. If equal to 1, then dr structure is saved with each prior draw.
|
% drsave [integer] Scalar. If equal to 1, then dr structure is saved with each prior draw.
|
||||||
% M_ [structure] Model description.
|
% M_ [structure] Model description.
|
||||||
% bayestopt_ [structure] Prior distribution description.
|
% bayestopt_ [structure] Prior distribution description.
|
||||||
% options_ [structure] Global options of Dynare.
|
% options_ [structure] Global options of Dynare.
|
||||||
%
|
%
|
||||||
% OUTPUTS:
|
% OUTPUTS:
|
||||||
% results [structure] Various statistics.
|
% results [structure] Various statistics.
|
||||||
%
|
%
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
% none
|
% none
|
||||||
|
@ -80,7 +80,7 @@ while iteration < NumberOfSimulations
|
||||||
loop_indx = loop_indx+1;
|
loop_indx = loop_indx+1;
|
||||||
params = prior_draw();
|
params = prior_draw();
|
||||||
set_all_parameters(params);
|
set_all_parameters(params);
|
||||||
[dr,INFO] = resol(oo_.steady_state,work);
|
[dr,INFO,M_,options_,oo_] = resol(work,M_,options_,oo_);
|
||||||
switch INFO(1)
|
switch INFO(1)
|
||||||
case 0
|
case 0
|
||||||
file_line_number = file_line_number + 1 ;
|
file_line_number = file_line_number + 1 ;
|
||||||
|
|
228
matlab/resol.m
228
matlab/resol.m
|
@ -1,32 +1,80 @@
|
||||||
function [dr,info]=resol(steady_state_0,check_flag)
|
function [dr,info,M,options,oo] = resol(check_flag,M,options,oo)
|
||||||
% function [dr,info]=resol(steady_state_0,check_flag)
|
|
||||||
% Computes first and second order approximations
|
%@info:
|
||||||
%
|
%! @deftypefn {Function File} {[@var{dr},@var{info},@var{M},@var{options},@var{oo}] =} resol (@var{check_flag},@var{M},@var{options},@var{oo})
|
||||||
% INPUTS
|
%! @anchor{resol}
|
||||||
% steady_state_0: vector of variables in steady state
|
%! @sp 1
|
||||||
% check_flag=0: all the approximation is computed
|
%! Computes first and second order reduced form of the DSGE model.
|
||||||
% check_flag=1: computes only the eigenvalues
|
%! @sp 2
|
||||||
%
|
%! @strong{Inputs}
|
||||||
% OUTPUTS
|
%! @sp 1
|
||||||
% dr: structure of decision rules for stochastic simulations
|
%! @table @ @var
|
||||||
% info=1: the model doesn't determine the current variables '...' uniquely
|
%! @item check_flag
|
||||||
% info=2: MJDGGES returns the following error code'
|
%! Integer scalar, equal to 0 if all the approximation is required, positive if only the eigenvalues are to be computed.
|
||||||
% info=3: Blanchard Kahn conditions are not satisfied: no stable '...' equilibrium
|
%! @item M
|
||||||
% info=4: Blanchard Kahn conditions are not satisfied:'...' indeterminacy
|
%! Matlab's structure describing the model (initialized by @code{dynare}).
|
||||||
% info=5: Blanchard Kahn conditions are not satisfied:'...' indeterminacy due to rank failure
|
%! @item options
|
||||||
% info=6: The jacobian evaluated at the steady state is complex.
|
%! Matlab's structure describing the options (initialized by @code{dynare}).
|
||||||
% info=19: The steadystate file did not compute the steady state (inconsistent deep parameters).
|
%! @item oo
|
||||||
% info=20: can't find steady state info(2) contains sum of sqare residuals
|
%! Matlab's structure gathering the results (initialized by @code{dynare}).
|
||||||
% info=21: steady state is complex valued scalars
|
%! @end table
|
||||||
% info(2) contains sum of square of
|
%! @sp 2
|
||||||
% imaginary part of steady state
|
%! @strong{Outputs}
|
||||||
% info=22: steady state has NaNs
|
%! @sp 1
|
||||||
% info=23: M_.params has been updated in the steady state file and has complex valued scalars.
|
%! @table @ @var
|
||||||
% info=24: M_.params has been updated in the steady state file and has some NaNs.
|
%! @item dr
|
||||||
% info=30: Variance can't be computed
|
%! Matlab's structure describing the reduced form solution of the model.
|
||||||
%
|
%! @item info
|
||||||
% SPECIAL REQUIREMENTS
|
%! Integer scalar, error code.
|
||||||
% none
|
%! @sp 1
|
||||||
|
%! @table @ @code
|
||||||
|
%! @item info==0
|
||||||
|
%! No error.
|
||||||
|
%! @item info==1
|
||||||
|
%! The model doesn't determine the current variables uniquely.
|
||||||
|
%! @item info==2
|
||||||
|
%! MJDGGES returned an error code.
|
||||||
|
%! @item info==3
|
||||||
|
%! Blanchard & Kahn conditions are not satisfied: no stable equilibrium.
|
||||||
|
%! @item info==4
|
||||||
|
%! Blanchard & Kahn conditions are not satisfied: indeterminacy.
|
||||||
|
%! @item info==5
|
||||||
|
%! Blanchard & Kahn conditions are not satisfied: indeterminacy due to rank failure.
|
||||||
|
%! @item info==6
|
||||||
|
%! The jacobian evaluated at the deterministic steady state is complex.
|
||||||
|
%! @item info==19
|
||||||
|
%! The steadystate routine thrown an exception (inconsistent deep parameters).
|
||||||
|
%! @item info==20
|
||||||
|
%! Cannot find the steady state, info(2) contains the sum of square residuals (of the static equations).
|
||||||
|
%! @item info==21
|
||||||
|
%! The steady state is complex, info(2) contains the sum of square of imaginary parts of the steady state.
|
||||||
|
%! @item info==22
|
||||||
|
%! The steady has NaNs.
|
||||||
|
%! @item info==23
|
||||||
|
%! M_.params has been updated in the steadystate routine and has complex valued scalars.
|
||||||
|
%! @item info==24
|
||||||
|
%! M_.params has been updated in the steadystate routine and has some NaNs.
|
||||||
|
%! @item info==30
|
||||||
|
%! Ergodic variance can't be computed.
|
||||||
|
%! @end table
|
||||||
|
%! @sp 1
|
||||||
|
%! @item M
|
||||||
|
%! Matlab's structure describing the model (initialized by @code{dynare}).
|
||||||
|
%! @item options
|
||||||
|
%! Matlab's structure describing the options (initialized by @code{dynare}).
|
||||||
|
%! @item oo
|
||||||
|
%! Matlab's structure gathering the results (initialized by @code{dynare}).
|
||||||
|
%! @end table
|
||||||
|
%! @sp 2
|
||||||
|
%! @strong{This function is called by:}
|
||||||
|
%! @sp 1
|
||||||
|
%! @ref{dynare_estimation_init}
|
||||||
|
%! @sp 2
|
||||||
|
%! @strong{This function calls:}
|
||||||
|
%! @sp 1
|
||||||
|
%! None.
|
||||||
|
%! @end deftypefn
|
||||||
|
%@eod:
|
||||||
|
|
||||||
% Copyright (C) 2001-2011 Dynare Team
|
% Copyright (C) 2001-2011 Dynare Team
|
||||||
%
|
%
|
||||||
|
@ -45,94 +93,93 @@ function [dr,info]=resol(steady_state_0,check_flag)
|
||||||
% 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 M_ options_ oo_
|
|
||||||
global it_
|
global it_
|
||||||
|
|
||||||
jacobian_flag = 0;
|
jacobian_flag = 0;
|
||||||
|
|
||||||
if isfield(oo_,'dr');
|
if isfield(oo,'dr');
|
||||||
dr = oo_.dr;
|
dr = oo.dr;
|
||||||
end
|
end
|
||||||
|
|
||||||
options_ = set_default_option(options_,'jacobian_flag',1);
|
options = set_default_option(options,'jacobian_flag',1);
|
||||||
info = 0;
|
info = 0;
|
||||||
|
|
||||||
it_ = M_.maximum_lag + 1 ;
|
it_ = M.maximum_lag + 1 ;
|
||||||
|
|
||||||
if M_.exo_nbr == 0
|
if M.exo_nbr == 0
|
||||||
oo_.exo_steady_state = [] ;
|
oo.exo_steady_state = [] ;
|
||||||
end
|
end
|
||||||
|
|
||||||
params0 = M_.params;
|
params0 = M.params;
|
||||||
|
|
||||||
% check if steady_state_0 is steady state
|
% check if steady_state_0 is steady state
|
||||||
tempex = oo_.exo_simul;
|
tempex = oo.exo_simul;
|
||||||
oo_.exo_simul = repmat(oo_.exo_steady_state',M_.maximum_lag+M_.maximum_lead+1,1);
|
oo.exo_simul = repmat(oo.exo_steady_state',M.maximum_lag+M.maximum_lead+1,1);
|
||||||
if M_.exo_det_nbr > 0
|
if M.exo_det_nbr > 0
|
||||||
tempexdet = oo_.exo_det_simul;
|
tempexdet = oo.exo_det_simul;
|
||||||
oo_.exo_det_simul = repmat(oo_.exo_det_steady_state',M_.maximum_lag+M_.maximum_lead+1,1);
|
oo.exo_det_simul = repmat(oo.exo_det_steady_state',M.maximum_lag+M.maximum_lead+1,1);
|
||||||
end
|
end
|
||||||
steady_state = steady_state_0;
|
steady_state = steady_state_0;
|
||||||
check1 = 0;
|
check1 = 0;
|
||||||
% testing for steadystate file
|
% testing for steadystate file
|
||||||
if (~options_.bytecode)
|
if (~options.bytecode)
|
||||||
fh = str2func([M_.fname '_static']);
|
fh = str2func([M.fname '_static']);
|
||||||
end
|
end
|
||||||
|
|
||||||
if options_.steadystate_flag
|
if options.steadystate_flag
|
||||||
[steady_state,check1] = feval([M_.fname '_steadystate'],steady_state,...
|
[steady_state,check1] = feval([M.fname '_steadystate'],steady_state,...
|
||||||
[oo_.exo_steady_state; ...
|
[oo.exo_steady_state; ...
|
||||||
oo_.exo_det_steady_state]);
|
oo.exo_det_steady_state]);
|
||||||
if size(steady_state,1) < M_.endo_nbr
|
if size(steady_state,1) < M.endo_nbr
|
||||||
if length(M_.aux_vars) > 0
|
if length(M.aux_vars) > 0
|
||||||
steady_state = add_auxiliary_variables_to_steadystate(steady_state,M_.aux_vars,...
|
steady_state = add_auxiliary_variables_to_steadystate(steady_state,M.aux_vars,...
|
||||||
M_.fname,...
|
M.fname,...
|
||||||
oo_.exo_steady_state,...
|
oo.exo_steady_state,...
|
||||||
oo_.exo_det_steady_state,...
|
oo.exo_det_steady_state,...
|
||||||
M_.params,...
|
M.params,...
|
||||||
options_.bytecode);
|
options.bytecode);
|
||||||
else
|
else
|
||||||
error([M_.fname '_steadystate.m doesn''t match the model']);
|
error([M.fname '_steadystate.m doesn''t match the model']);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
% testing if steady_state_0 isn't a steady state or if we aren't computing Ramsey policy
|
% testing if steady_state_0 isn't a steady state or if we aren't computing Ramsey policy
|
||||||
if options_.ramsey_policy == 0
|
if options.ramsey_policy == 0
|
||||||
if options_.linear == 0
|
if options.linear == 0
|
||||||
% nonlinear models
|
% nonlinear models
|
||||||
if (options_.block == 0 && options_.bytecode == 0)
|
if (options.block == 0 && options.bytecode == 0)
|
||||||
if max(abs(feval(fh,steady_state,[oo_.exo_steady_state; ...
|
if max(abs(feval(fh,steady_state,[oo.exo_steady_state; ...
|
||||||
oo_.exo_det_steady_state], M_.params))) > options_.dynatol
|
oo.exo_det_steady_state], M.params))) > options.dynatol
|
||||||
[steady_state,check1] = dynare_solve(fh,steady_state,options_.jacobian_flag,...
|
[steady_state,check1] = dynare_solve(fh,steady_state,options.jacobian_flag,...
|
||||||
[oo_.exo_steady_state; ...
|
[oo.exo_steady_state; ...
|
||||||
oo_.exo_det_steady_state], M_.params);
|
oo.exo_det_steady_state], M.params);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
[steady_state,check1] = dynare_solve_block_or_bytecode(steady_state,...
|
[steady_state,check1] = dynare_solve_block_or_bytecode(steady_state,...
|
||||||
[oo_.exo_steady_state; ...
|
[oo.exo_steady_state; ...
|
||||||
oo_.exo_det_steady_state], M_.params);
|
oo.exo_det_steady_state], M.params);
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
if (options_.block == 0 && options_.bytecode == 0)
|
if (options.block == 0 && options.bytecode == 0)
|
||||||
% linear models
|
% linear models
|
||||||
[fvec,jacob] = feval(fh,steady_state,[oo_.exo_steady_state;...
|
[fvec,jacob] = feval(fh,steady_state,[oo.exo_steady_state;...
|
||||||
oo_.exo_det_steady_state], M_.params);
|
oo.exo_det_steady_state], M.params);
|
||||||
if max(abs(fvec)) > 1e-12
|
if max(abs(fvec)) > 1e-12
|
||||||
steady_state = steady_state-jacob\fvec;
|
steady_state = steady_state-jacob\fvec;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
[steady_state,check1] = dynare_solve_block_or_bytecode(steady_state,...
|
[steady_state,check1] = dynare_solve_block_or_bytecode(steady_state,...
|
||||||
[oo_.exo_steady_state; ...
|
[oo.exo_steady_state; ...
|
||||||
oo_.exo_det_steady_state], M_.params);
|
oo.exo_det_steady_state], M.params);
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
% test if M_.params_has changed.
|
% test if M.params_has changed.
|
||||||
if options_.steadystate_flag
|
if options.steadystate_flag
|
||||||
updated_params_flag = max(abs(M_.params-params0))>1e-12;
|
updated_params_flag = max(abs(M.params-params0))>1e-12;
|
||||||
else
|
else
|
||||||
updated_params_flag = 0;
|
updated_params_flag = 0;
|
||||||
end
|
end
|
||||||
|
@ -141,12 +188,12 @@ end
|
||||||
dr.ys = steady_state;
|
dr.ys = steady_state;
|
||||||
|
|
||||||
if check1
|
if check1
|
||||||
if options_.steadystate_flag
|
if options.steadystate_flag
|
||||||
info(1)= 19;
|
info(1)= 19;
|
||||||
resid = check1 ;
|
resid = check1 ;
|
||||||
else
|
else
|
||||||
info(1)= 20;
|
info(1)= 20;
|
||||||
resid = feval(fh,steady_state_0,oo_.exo_steady_state, M_.params);
|
resid = feval(fh,steady_state_0,oo.exo_steady_state, M.params);
|
||||||
end
|
end
|
||||||
info(2) = resid'*resid ;
|
info(2) = resid'*resid ;
|
||||||
return
|
return
|
||||||
|
@ -167,14 +214,14 @@ if ~isempty(find(isnan(steady_state)))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if options_.steadystate_flag && updated_params_flag && ~isreal(M_.params)
|
if options.steadystate_flag && updated_params_flag && ~isreal(M.params)
|
||||||
info(1) = 23;
|
info(1) = 23;
|
||||||
info(2) = sum(imag(M_.params).^2);
|
info(2) = sum(imag(M.params).^2);
|
||||||
dr.ys = steady_state;
|
dr.ys = steady_state;
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if options_.steadystate_flag && updated_params_flag && ~isempty(find(isnan(M_.params)))
|
if options.steadystate_flag && updated_params_flag && ~isempty(find(isnan(M.params)))
|
||||||
info(1) = 24;
|
info(1) = 24;
|
||||||
info(2) = NaN;
|
info(2) = NaN;
|
||||||
dr.ys = steady_state;
|
dr.ys = steady_state;
|
||||||
|
@ -182,22 +229,17 @@ if options_.steadystate_flag && updated_params_flag && ~isempty(find(isnan(M_.p
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if options_.block
|
if options.block
|
||||||
[dr,info,M_,options_,oo_] = dr_block(dr,check_flag,M_,options_,oo_);
|
[dr,info,M,options,oo] = dr_block(dr,check_flag,M,options,oo);
|
||||||
else
|
else
|
||||||
[dr,info,M_,options_,oo_] = dr1(dr,check_flag,M_,options_,oo_);
|
[dr,info,M,options,oo] = dr1(dr,check_flag,M,options,oo);
|
||||||
end
|
end
|
||||||
if info(1)
|
if info(1)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if M_.exo_det_nbr > 0
|
if M.exo_det_nbr > 0
|
||||||
oo_.exo_det_simul = tempexdet;
|
oo.exo_det_simul = tempexdet;
|
||||||
end
|
end
|
||||||
oo_.exo_simul = tempex;
|
oo.exo_simul = tempex;
|
||||||
tempex = [];
|
tempex = [];
|
||||||
|
|
||||||
% 01/01/2003 MJ added dr_algo == 1
|
|
||||||
% 08/24/2001 MJ uses Schmitt-Grohe and Uribe (2001) constant correction
|
|
||||||
% in dr.ghs2
|
|
||||||
% 05/26/2003 MJ added temporary values for oo_.exo_simul
|
|
|
@ -1,17 +1,17 @@
|
||||||
function innovation_paths = reversed_extended_path(controlled_variable_names, control_innovation_names, dataset)
|
function innovation_paths = reversed_extended_path(controlled_variable_names, control_innovation_names, dataset)
|
||||||
% Inversion of the extended path simulation approach. This routine computes the innovations needed to
|
% Inversion of the extended path simulation approach. This routine computes the innovations needed to
|
||||||
% reproduce the time path of a subset of endogenous variables. The initial condition is teh deterministic
|
% reproduce the time path of a subset of endogenous variables. The initial condition is teh deterministic
|
||||||
% steady state.
|
% steady state.
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% o controlled_variable_names [string] n*1 matlab's cell.
|
% o controlled_variable_names [string] n*1 matlab's cell.
|
||||||
% o control_innovation_names [string] n*1 matlab's cell.
|
% o control_innovation_names [string] n*1 matlab's cell.
|
||||||
% o dataset [structure]
|
% o dataset [structure]
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% o innovations [double] n*T matrix.
|
% o innovations [double] n*T matrix.
|
||||||
%
|
%
|
||||||
% ALGORITHM
|
% ALGORITHM
|
||||||
%
|
%
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
|
|
||||||
% Copyright (C) 2010 Dynare Team.
|
% Copyright (C) 2010 Dynare Team.
|
||||||
|
@ -31,7 +31,7 @@ function innovation_paths = reversed_extended_path(controlled_variable_names, co
|
||||||
% 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 M_ oo_ options_
|
global M_ oo_ options_
|
||||||
|
|
||||||
%% Initialization
|
%% Initialization
|
||||||
|
|
||||||
|
@ -48,14 +48,14 @@ steady_;
|
||||||
|
|
||||||
% Compute the first order perturbation reduced form.
|
% Compute the first order perturbation reduced form.
|
||||||
old_options_order = options_.order; options_.order = 1;
|
old_options_order = options_.order; options_.order = 1;
|
||||||
[oo_.dr,info] = resol(oo_.steady_state,0);
|
[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
options_.order = old_options_order;
|
options_.order = old_options_order;
|
||||||
|
|
||||||
% Set various options.
|
% Set various options.
|
||||||
options_.periods = 100;
|
options_.periods = 100;
|
||||||
|
|
||||||
% Set-up oo_.exo_simul.
|
% Set-up oo_.exo_simul.
|
||||||
make_ex_;
|
make_ex_;
|
||||||
|
|
||||||
% Set-up oo_.endo_simul.
|
% Set-up oo_.endo_simul.
|
||||||
make_y_;
|
make_y_;
|
||||||
|
@ -98,13 +98,13 @@ for t=1:T
|
||||||
total_variation = y_target-transpose(oo_.endo_simul(t+M_.maximum_lag,iy));
|
total_variation = y_target-transpose(oo_.endo_simul(t+M_.maximum_lag,iy));
|
||||||
for i=1:100
|
for i=1:100
|
||||||
[t,i]
|
[t,i]
|
||||||
y = transpose(oo_.endo_simul(t+M_.maximum_lag,iy)) + (i/100)*y_target
|
y = transpose(oo_.endo_simul(t+M_.maximum_lag,iy)) + (i/100)*y_target
|
||||||
[tmp,fval,exitflag] = fsolve('ep_residuals', x0, options, y, ix, iy, oo_.steady_state, oo_.dr, M_.maximum_lag, M_.endo_nbr);
|
[tmp,fval,exitflag] = fsolve('ep_residuals', x0, options, y, ix, iy, oo_.steady_state, oo_.dr, M_.maximum_lag, M_.endo_nbr);
|
||||||
end
|
end
|
||||||
if exitflag==1
|
if exitflag==1
|
||||||
innovation_paths(:,t) = tmp;
|
innovation_paths(:,t) = tmp;
|
||||||
end
|
end
|
||||||
% Update endo_simul.
|
% Update endo_simul.
|
||||||
oo_.endo_simul(:,1:end-1) = oo_.endo_simul(:,2:end);
|
oo_.endo_simul(:,1:end-1) = oo_.endo_simul(:,2:end);
|
||||||
oo_.endo_simul(:,end) = oo_.steady_state;
|
oo_.endo_simul(:,end) = oo_.steady_state;
|
||||||
end
|
end
|
|
@ -1,24 +1,24 @@
|
||||||
function SampleAddress = selec_posterior_draws(SampleSize,drsize)
|
function SampleAddress = selec_posterior_draws(SampleSize,drsize)
|
||||||
% Selects a sample of draws from the posterior distribution and if nargin>1
|
% Selects a sample of draws from the posterior distribution and if nargin>1
|
||||||
% saves the draws in _pdraws mat files (metropolis folder). If drsize>0
|
% saves the draws in _pdraws mat files (metropolis folder). If drsize>0
|
||||||
% the dr structure, associated to the parameters, is also saved in _pdraws.
|
% the dr structure, associated to the parameters, is also saved in _pdraws.
|
||||||
% This routine is more efficient than metropolis_draw.m because here an
|
% This routine is more efficient than metropolis_draw.m because here an
|
||||||
% _mh file cannot be opened twice.
|
% _mh file cannot be opened twice.
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% o SampleSize [integer] Size of the sample to build.
|
% o SampleSize [integer] Size of the sample to build.
|
||||||
% o drsize [double] structure dr is drsize megaoctets.
|
% o drsize [double] structure dr is drsize megaoctets.
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% o SampleAddress [integer] A (SampleSize*4) array, each line specifies the
|
% o SampleAddress [integer] A (SampleSize*4) array, each line specifies the
|
||||||
% location of a posterior draw:
|
% location of a posterior draw:
|
||||||
% Column 2 --> Chain number
|
% Column 2 --> Chain number
|
||||||
% Column 3 --> (mh) File number
|
% Column 3 --> (mh) File number
|
||||||
% Column 4 --> (mh) line number
|
% Column 4 --> (mh) line number
|
||||||
%
|
%
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
% None.
|
% None.
|
||||||
%
|
%
|
||||||
|
|
||||||
% Copyright (C) 2006-2011 Dynare Team
|
% Copyright (C) 2006-2011 Dynare Team
|
||||||
%
|
%
|
||||||
|
@ -46,7 +46,7 @@ npar = npar + estim_params_.ncx;
|
||||||
npar = npar + estim_params_.ncn;
|
npar = npar + estim_params_.ncn;
|
||||||
npar = npar + estim_params_.np;
|
npar = npar + estim_params_.np;
|
||||||
|
|
||||||
% Select one task:
|
% Select one task:
|
||||||
switch nargin
|
switch nargin
|
||||||
case 1
|
case 1
|
||||||
info = 0;
|
info = 0;
|
||||||
|
@ -62,14 +62,14 @@ switch nargin
|
||||||
error(['selec_posterior_draws:: Unexpected number of input arguments!'])
|
error(['selec_posterior_draws:: Unexpected number of input arguments!'])
|
||||||
end
|
end
|
||||||
|
|
||||||
% Get informations about the mcmc:
|
% Get informations about the mcmc:
|
||||||
MhDirectoryName = CheckPath('metropolis');
|
MhDirectoryName = CheckPath('metropolis');
|
||||||
fname = [ MhDirectoryName '/' M_.fname];
|
fname = [ MhDirectoryName '/' M_.fname];
|
||||||
load([ fname '_mh_history.mat']);
|
load([ fname '_mh_history.mat']);
|
||||||
FirstMhFile = record.KeepedDraws.FirstMhFile;
|
FirstMhFile = record.KeepedDraws.FirstMhFile;
|
||||||
FirstLine = record.KeepedDraws.FirstLine;
|
FirstLine = record.KeepedDraws.FirstLine;
|
||||||
TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
|
TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
|
||||||
LastMhFile = TotalNumberOfMhFiles;
|
LastMhFile = TotalNumberOfMhFiles;
|
||||||
TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
|
TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
|
||||||
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
|
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
|
||||||
MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8);
|
MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8);
|
||||||
|
@ -87,7 +87,7 @@ for i = 1:SampleSize
|
||||||
MhLineNumber = FirstLine+DrawNumber-1;
|
MhLineNumber = FirstLine+DrawNumber-1;
|
||||||
else
|
else
|
||||||
DrawNumber = DrawNumber-(MAX_nruns-FirstLine+1);
|
DrawNumber = DrawNumber-(MAX_nruns-FirstLine+1);
|
||||||
MhFileNumber = FirstMhFile+ceil(DrawNumber/MAX_nruns);
|
MhFileNumber = FirstMhFile+ceil(DrawNumber/MAX_nruns);
|
||||||
MhLineNumber = DrawNumber-(MhFileNumber-FirstMhFile-1)*MAX_nruns;
|
MhLineNumber = DrawNumber-(MhFileNumber-FirstMhFile-1)*MAX_nruns;
|
||||||
end
|
end
|
||||||
SampleAddress(i,3) = MhFileNumber;
|
SampleAddress(i,3) = MhFileNumber;
|
||||||
|
@ -111,7 +111,7 @@ if info
|
||||||
pdraws(i,1) = {x2(SampleAddress(i,4),:)};
|
pdraws(i,1) = {x2(SampleAddress(i,4),:)};
|
||||||
if info-1
|
if info-1
|
||||||
set_parameters(pdraws{i,1});
|
set_parameters(pdraws{i,1});
|
||||||
[dr,info] = resol(oo_.steady_state,0);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
pdraws(i,2) = { dr };
|
pdraws(i,2) = { dr };
|
||||||
end
|
end
|
||||||
old_mhfile = mhfile;
|
old_mhfile = mhfile;
|
||||||
|
@ -121,7 +121,7 @@ if info
|
||||||
save([fname '_posterior_draws1.mat'],'pdraws')
|
save([fname '_posterior_draws1.mat'],'pdraws')
|
||||||
else% The posterior draws are saved in xx files.
|
else% The posterior draws are saved in xx files.
|
||||||
NumberOfDrawsPerFile = fix(MAX_mega_bytes/drawsize);
|
NumberOfDrawsPerFile = fix(MAX_mega_bytes/drawsize);
|
||||||
NumberOfFiles = ceil(SampleSize*drawsize/MAX_mega_bytes);
|
NumberOfFiles = ceil(SampleSize*drawsize/MAX_mega_bytes);
|
||||||
NumberOfLines = SampleSize - (NumberOfFiles-1)*NumberOfDrawsPerFile;
|
NumberOfLines = SampleSize - (NumberOfFiles-1)*NumberOfDrawsPerFile;
|
||||||
linee = 0;
|
linee = 0;
|
||||||
fnum = 1;
|
fnum = 1;
|
||||||
|
@ -138,7 +138,7 @@ if info
|
||||||
pdraws(linee,1) = {x2(SampleAddress(i,4),:)};
|
pdraws(linee,1) = {x2(SampleAddress(i,4),:)};
|
||||||
if info-1
|
if info-1
|
||||||
set_parameters(pdraws{linee,1});
|
set_parameters(pdraws{linee,1});
|
||||||
[dr,info] = resol(oo_.steady_state,0);
|
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
pdraws(linee,2) = { dr };
|
pdraws(linee,2) = { dr };
|
||||||
end
|
end
|
||||||
old_mhfile = mhfile;
|
old_mhfile = mhfile;
|
||||||
|
|
|
@ -69,7 +69,7 @@ elseif options_.discretionary_policy
|
||||||
end
|
end
|
||||||
[oo_.dr,ys,info] = discretionary_policy_1(oo_,options_.instruments);
|
[oo_.dr,ys,info] = discretionary_policy_1(oo_,options_.instruments);
|
||||||
else
|
else
|
||||||
[oo_.dr, info] = resol(oo_.steady_state,0);
|
[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
end
|
end
|
||||||
|
|
||||||
if info(1)
|
if info(1)
|
||||||
|
@ -137,14 +137,14 @@ if options_.nomoments == 0
|
||||||
if PI_PCL_solver
|
if PI_PCL_solver
|
||||||
PCL_Part_info_moments (0, PCL_varobs, oo_.dr, i_var);
|
PCL_Part_info_moments (0, PCL_varobs, oo_.dr, i_var);
|
||||||
elseif options_.periods == 0
|
elseif options_.periods == 0
|
||||||
disp_th_moments(oo_.dr,var_list);
|
disp_th_moments(oo_.dr,var_list);
|
||||||
else
|
else
|
||||||
disp_moments(oo_.endo_simul,var_list);
|
disp_moments(oo_.endo_simul,var_list);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if options_.irf
|
if options_.irf
|
||||||
var_listTeX = M_.endo_names_tex(i_var,:);
|
var_listTeX = M_.endo_names_tex(i_var,:);
|
||||||
|
|
||||||
if TeX
|
if TeX
|
||||||
|
@ -169,7 +169,7 @@ if options_.irf
|
||||||
options_.replic, options_.order);
|
options_.replic, options_.order);
|
||||||
end
|
end
|
||||||
if options_.relative_irf
|
if options_.relative_irf
|
||||||
y = 100*y/cs(i,i);
|
y = 100*y/cs(i,i);
|
||||||
end
|
end
|
||||||
irfs = [];
|
irfs = [];
|
||||||
mylist = [];
|
mylist = [];
|
||||||
|
@ -180,7 +180,7 @@ if options_.irf
|
||||||
assignin('base',[deblank(M_.endo_names(i_var(j),:)) '_' deblank(M_.exo_names(i,:))],...
|
assignin('base',[deblank(M_.endo_names(i_var(j),:)) '_' deblank(M_.exo_names(i,:))],...
|
||||||
y(i_var(j),:)');
|
y(i_var(j),:)');
|
||||||
eval(['oo_.irfs.' deblank(M_.endo_names(i_var(j),:)) '_' ...
|
eval(['oo_.irfs.' deblank(M_.endo_names(i_var(j),:)) '_' ...
|
||||||
deblank(M_.exo_names(i,:)) ' = y(i_var(j),:);']);
|
deblank(M_.exo_names(i,:)) ' = y(i_var(j),:);']);
|
||||||
if max(y(i_var(j),:)) - min(y(i_var(j),:)) > 1e-10
|
if max(y(i_var(j),:)) - min(y(i_var(j),:)) > 1e-10
|
||||||
irfs = cat(1,irfs,y(i_var(j),:));
|
irfs = cat(1,irfs,y(i_var(j),:));
|
||||||
if isempty(mylist)
|
if isempty(mylist)
|
||||||
|
@ -280,7 +280,7 @@ if options_.irf
|
||||||
% close(hh);
|
% close(hh);
|
||||||
end
|
end
|
||||||
hh = figure('Name',['Orthogonalized shock to ' tit(i,:) ' figure ' int2str(nbplt) '.']);
|
hh = figure('Name',['Orthogonalized shock to ' tit(i,:) ' figure ' int2str(nbplt) '.']);
|
||||||
m = 0;
|
m = 0;
|
||||||
for plt = 1:number_of_plots_to_draw-(nbplt-1)*nstar;
|
for plt = 1:number_of_plots_to_draw-(nbplt-1)*nstar;
|
||||||
m = m+1;
|
m = m+1;
|
||||||
subplot(lr,lc,m);
|
subplot(lr,lc,m);
|
||||||
|
@ -333,4 +333,4 @@ end
|
||||||
|
|
||||||
options_ = options_old;
|
options_ = options_old;
|
||||||
% temporary fix waiting for local options
|
% temporary fix waiting for local options
|
||||||
options_.partial_information = 0;
|
options_.partial_information = 0;
|
|
@ -38,13 +38,13 @@ end
|
||||||
|
|
||||||
check_model;
|
check_model;
|
||||||
|
|
||||||
[oo_.dr, info] = resol(oo_.steady_state,0);
|
[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
|
||||||
|
|
||||||
if info(1)
|
if info(1)
|
||||||
options_ = options_old;
|
options_ = options_old;
|
||||||
print_info(info, options_.noprint);
|
print_info(info, options_.noprint);
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
oo_dr_kstate = [];
|
oo_dr_kstate = [];
|
||||||
oo_dr_nstatic = 0;
|
oo_dr_nstatic = 0;
|
||||||
|
@ -74,7 +74,7 @@ if ~options_.noprint
|
||||||
end
|
end
|
||||||
|
|
||||||
if options_.periods == 0 && options_.nomoments == 0
|
if options_.periods == 0 && options_.nomoments == 0
|
||||||
disp_th_moments(oo_.dr,var_list);
|
disp_th_moments(oo_.dr,var_list);
|
||||||
elseif options_.periods ~= 0
|
elseif options_.periods ~= 0
|
||||||
if options_.periods < options_.drop
|
if options_.periods < options_.drop
|
||||||
disp(['STOCH_SIMUL error: The horizon of simulation is shorter' ...
|
disp(['STOCH_SIMUL error: The horizon of simulation is shorter' ...
|
||||||
|
@ -91,7 +91,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if options_.irf
|
if options_.irf
|
||||||
if size(var_list,1) == 0
|
if size(var_list,1) == 0
|
||||||
var_list = M_.endo_names(1:M_.orig_endo_nbr, :);
|
var_list = M_.endo_names(1:M_.orig_endo_nbr, :);
|
||||||
if TeX
|
if TeX
|
||||||
|
@ -138,7 +138,7 @@ if options_.irf
|
||||||
y=irf(oo_.dr,cs(M_.exo_names_orig_ord,i), options_.irf, options_.drop, ...
|
y=irf(oo_.dr,cs(M_.exo_names_orig_ord,i), options_.irf, options_.drop, ...
|
||||||
options_.replic, options_.order);
|
options_.replic, options_.order);
|
||||||
if options_.relative_irf
|
if options_.relative_irf
|
||||||
y = 100*y/cs(i,i);
|
y = 100*y/cs(i,i);
|
||||||
end
|
end
|
||||||
irfs = [];
|
irfs = [];
|
||||||
mylist = [];
|
mylist = [];
|
||||||
|
@ -149,7 +149,7 @@ if options_.irf
|
||||||
assignin('base',[deblank(M_.endo_names(ivar(j),:)) '_' deblank(M_.exo_names(i,:))],...
|
assignin('base',[deblank(M_.endo_names(ivar(j),:)) '_' deblank(M_.exo_names(i,:))],...
|
||||||
y(ivar(j),:)');
|
y(ivar(j),:)');
|
||||||
eval(['oo_.irfs.' deblank(M_.endo_names(ivar(j),:)) '_' ...
|
eval(['oo_.irfs.' deblank(M_.endo_names(ivar(j),:)) '_' ...
|
||||||
deblank(M_.exo_names(i,:)) ' = y(ivar(j),:);']);
|
deblank(M_.exo_names(i,:)) ' = y(ivar(j),:);']);
|
||||||
if max(y(ivar(j),:)) - min(y(ivar(j),:)) > 1e-10
|
if max(y(ivar(j),:)) - min(y(ivar(j),:)) > 1e-10
|
||||||
irfs = cat(1,irfs,y(ivar(j),:));
|
irfs = cat(1,irfs,y(ivar(j),:));
|
||||||
if isempty(mylist)
|
if isempty(mylist)
|
||||||
|
@ -249,7 +249,7 @@ if options_.irf
|
||||||
% close(hh);
|
% close(hh);
|
||||||
end
|
end
|
||||||
hh = figure('Name',['Orthogonalized shock to ' tit(i,:) ' figure ' int2str(nbplt) '.']);
|
hh = figure('Name',['Orthogonalized shock to ' tit(i,:) ' figure ' int2str(nbplt) '.']);
|
||||||
m = 0;
|
m = 0;
|
||||||
for plt = 1:number_of_plots_to_draw-(nbplt-1)*nstar;
|
for plt = 1:number_of_plots_to_draw-(nbplt-1)*nstar;
|
||||||
m = m+1;
|
m = m+1;
|
||||||
subplot(lr,lc,m);
|
subplot(lr,lc,m);
|
||||||
|
|
Loading…
Reference in New Issue