diff --git a/matlab/PosteriorFilterSmootherAndForecast.m b/matlab/PosteriorFilterSmootherAndForecast.m
index fca2bd918..7836974d8 100644
--- a/matlab/PosteriorFilterSmootherAndForecast.m
+++ b/matlab/PosteriorFilterSmootherAndForecast.m
@@ -5,14 +5,14 @@ function PosteriorFilterSmootherAndForecast(Y,gend, type,data_index)
%
% INPUTS
% Y: data
-% gend: number of observations
+% gend: number of observations
% type: posterior
% prior
% gsa
-%
+%
% OUTPUTS
% none
-%
+%
% SPECIAL REQUIREMENTS
% none
@@ -59,8 +59,8 @@ CheckPath('Plots/');
DirectoryName = CheckPath('metropolis');
load([ DirectoryName '/' M_.fname '_mh_history.mat'])
FirstMhFile = record.KeepedDraws.FirstMhFile;
-FirstLine = record.KeepedDraws.FirstLine;
-TotalNumberOfMhFiles = sum(record.MhDraws(:,2)); LastMhFile = TotalNumberOfMhFiles;
+FirstLine = record.KeepedDraws.FirstLine;
+TotalNumberOfMhFiles = sum(record.MhDraws(:,2)); LastMhFile = TotalNumberOfMhFiles;
TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
clear record;
@@ -136,17 +136,17 @@ for b=1:B
%deep = GetOneDraw(NumberOfDraws,FirstMhFile,LastMhFile,FirstLine,MAX_nruns,DirectoryName);
[deep, logpo] = GetOneDraw(type);
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] = ...
DsgeSmoother(deep,gend,Y,data_index);
-
+
if options_.loglinear
stock_smooth(dr.order_var,:,irun1) = alphahat(1:endo_nbr,:)+ ...
repmat(log(dr.ys(dr.order_var)),1,gend);
else
stock_smooth(dr.order_var,:,irun1) = alphahat(1:endo_nbr,:)+ ...
repmat(dr.ys(dr.order_var),1,gend);
- end
+ end
if nvx
stock_innov(:,:,irun2) = etahat;
end
@@ -191,7 +191,7 @@ for b=1:B
stock_forcst_mean(:,:,irun6) = yf';
stock_forcst_total(:,:,irun7) = yf1';
end
-
+
irun1 = irun1 + 1;
irun2 = irun2 + 1;
irun3 = irun3 + 1;
@@ -206,28 +206,28 @@ for b=1:B
save([DirectoryName '/' M_.fname '_smooth' int2str(ifil1) '.mat'],'stock');
irun1 = 1;
end
-
+
if nvx && (irun2 > MAX_ninno || b == B)
stock = stock_innov(:,:,1:irun2-1);
ifil2 = ifil2 + 1;
save([DirectoryName '/' M_.fname '_inno' int2str(ifil2) '.mat'],'stock');
irun2 = 1;
end
-
+
if nvn && (irun3 > MAX_error || b == B)
stock = stock_error(:,:,1:irun3-1);
ifil3 = ifil3 + 1;
save([DirectoryName '/' M_.fname '_error' int2str(ifil3) '.mat'],'stock');
irun3 = 1;
end
-
+
if naK && (irun4 > MAX_naK || b == B)
stock = stock_filter(:,:,:,1:irun4-1);
ifil4 = ifil4 + 1;
save([DirectoryName '/' M_.fname '_filter' int2str(ifil4) '.mat'],'stock');
irun4 = 1;
end
-
+
if irun5 > MAX_nruns || b == B
stock = stock_param(1:irun5-1,:);
ifil5 = ifil5 + 1;
diff --git a/matlab/PosteriorIRF_core1.m b/matlab/PosteriorIRF_core1.m
index ea7782ea4..118229257 100644
--- a/matlab/PosteriorIRF_core1.m
+++ b/matlab/PosteriorIRF_core1.m
@@ -150,7 +150,7 @@ while fpar.
-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
A = [];
diff --git a/matlab/evaluate_likelihood.m b/matlab/evaluate_likelihood.m
index 7e7a6b3be..cfb702701 100644
--- a/matlab/evaluate_likelihood.m
+++ b/matlab/evaluate_likelihood.m
@@ -2,20 +2,20 @@ function [llik,parameters] = evaluate_likelihood(parameters)
% Evaluate the logged likelihood at parameters.
%
% 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.
-%
-%
+%
+%
% OUTPUTS
% o ldens [double] value of the sample logged density at parameters.
% o parameters [double] vector of values for the estimated parameters.
-%
+%
% SPECIAL REQUIREMENTS
% None
%
% REMARKS
% [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.
% Copyright (C) 2009-2010 Dynare Team
@@ -77,7 +77,7 @@ if isempty(load_data)
% Transform the data.
if options_.loglinear
if ~options_.logdata
- rawdata = log(rawdata);
+ rawdata = log(rawdata);
end
end
% Test if the data set is real.
@@ -109,7 +109,7 @@ if isempty(load_data)
[ys,tchek] = feval([M_.fname '_steadystate'],...
[zeros(M_.exo_nbr,1);...
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
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
M_.fname,...
@@ -123,7 +123,7 @@ if isempty(load_data)
end
oo_.steady_state = ys;
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');
end
if all(abs(oo_.steady_state(bayestopt_.mfys))<1e-9)
diff --git a/matlab/evaluate_smoother.m b/matlab/evaluate_smoother.m
index 3bddb0844..0e792190d 100644
--- a/matlab/evaluate_smoother.m
+++ b/matlab/evaluate_smoother.m
@@ -2,10 +2,10 @@ function oo = evaluate_smoother(parameters)
% Evaluate the smoother at parameters.
%
% 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.
-%
-%
+%
+%
% OUTPUTS
% o oo [structure] results:
% - SmoothedVariables
@@ -16,12 +16,12 @@ function oo = evaluate_smoother(parameters)
% - SmoothedVariables
% - SmoothedVariables
% - SmoothedVariables
-%
+%
% SPECIAL REQUIREMENTS
% None
%
% 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.
% Copyright (C) 2010-2011 Dynare Team
@@ -83,7 +83,7 @@ if isempty(load_data)
% Transform the data.
if options_.loglinear
if ~options_.logdata
- rawdata = log(rawdata);
+ rawdata = log(rawdata);
end
end
% Test if the data set is real.
@@ -115,7 +115,7 @@ if isempty(load_data)
[ys,tchek] = feval([M_.fname '_steadystate'],...
[zeros(M_.exo_nbr,1);...
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
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
M_.fname,...
@@ -129,7 +129,7 @@ if isempty(load_data)
end
oo_.steady_state = ys;
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');
end
if all(abs(oo_.steady_state(bayestopt_.mfys))<1e-9)
diff --git a/matlab/extended_path.m b/matlab/extended_path.m
index 926c79d02..061cc894c 100644
--- a/matlab/extended_path.m
+++ b/matlab/extended_path.m
@@ -1,7 +1,7 @@
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
-% 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
% 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.
@@ -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
% init=0 previous solution 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
% o time_series [double] m*sample_size array, the simulations.
-%
+%
% ALGORITHM
-%
+%
% SPECIAL REQUIREMENTS
% 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
% along with Dynare. If not, see .
-global M_ oo_ options_
+global M_ oo_ options_
% Set default initial conditions.
-if isempty(initial_conditions)
- initial_conditions = repmat(oo_.steady_state,1,M_.maximum_lag);
+if isempty(initial_conditions)
+ initial_conditions = repmat(oo_.steady_state,1,M_.maximum_lag);
end
% Set default value for the last input argument
@@ -50,7 +50,7 @@ end
%options_.periods = 40;
% Initialize the exogenous variables.
-make_ex_;
+make_ex_;
% Initialize the endogenous variables.
make_y_;
@@ -59,7 +59,7 @@ make_y_;
if init
oldopt = options_;
options_.order = 1;
- [dr,info]=resol(oo_.steady_state,0);
+ [dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
oo_.dr = dr;
options_ = oldopt;
if init==2
@@ -68,16 +68,16 @@ if init
end
% 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.
-variances = diag(M_.Sigma_e);
-positive_var_indx = find(variances>0);
-covariance_matrix = M_.Sigma_e(positive_var_indx,positive_var_indx);
-number_of_structural_innovations = length(covariance_matrix);
-covariance_matrix_upper_cholesky = chol(covariance_matrix);
+variances = diag(M_.Sigma_e);
+positive_var_indx = find(variances>0);
+covariance_matrix = M_.Sigma_e(positive_var_indx,positive_var_indx);
+number_of_structural_innovations = length(covariance_matrix);
+covariance_matrix_upper_cholesky = chol(covariance_matrix);
-tdx = M_.maximum_lag+1;
+tdx = M_.maximum_lag+1;
norme = 0;
% Set verbose option
@@ -106,7 +106,7 @@ while (t<=sample_size)
if init==1
oo_.endo_simul = initial_path(:,1:end-1);
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
if init
@@ -141,7 +141,7 @@ while (t<=sample_size)
if new_draw
info.time = info.time+time;
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;
end
end
\ No newline at end of file
diff --git a/matlab/forcst_unc.m b/matlab/forcst_unc.m
index 71f6e083f..f5e2cf82f 100644
--- a/matlab/forcst_unc.m
+++ b/matlab/forcst_unc.m
@@ -71,7 +71,7 @@ for i=1:replic
params = rndprior(bayestopt_);
set_parameters(params);
% solve the model
- [dr,info] = resol(oo_.steady_state,0);
+ [dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
% discard problematic cases
if info
continue
@@ -123,7 +123,7 @@ end
% compute shock uncertainty around forecast with mean prior
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_1 = 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
save_results(yf_mean,'oo_.forecast.mean.',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(1)),'oo_.forecast.HPDinf.',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(2)),'oo_.forecast.HPDTotalsup.',var_list);
\ No newline at end of file
diff --git a/matlab/gsa/dynare_MC.m b/matlab/gsa/dynare_MC.m
index 3d13b5b51..daaeba47d 100644
--- a/matlab/gsa/dynare_MC.m
+++ b/matlab/gsa/dynare_MC.m
@@ -9,10 +9,10 @@ function dynare_MC(var_list_,OutDir,data,rawdata,data_info)
% Written by Marco Ratto, 2006
% Joint Research Centre, The European Commission,
% (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.
-% It is an experimental system. The Joint Research Centre of European Commission
+% 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
% assumes no responsibility whatsoever for its use by other parties
% and makes no guarantees, expressed or implied, about its quality, reliability, or any other
% 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.
%
-global M_ options_ oo_ estim_params_
+global M_ options_ oo_ estim_params_
global bayestopt_
% if options_.filtered_vars ~= 0 & options_.filter_step_ahead == 0
@@ -31,7 +31,7 @@ global bayestopt_
% else
% options_.nk = 0;
% end
-%
+%
options_.filter_step_ahead=1;
options_.nk = 1;
@@ -98,7 +98,7 @@ for b=1:B
ib=ib+1;
deep = x(b,:)';
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);
logpo2(b,1) = DsgeLikelihood(deep,gend,data,data_index,number_of_observations,no_more_missing_observations);
if opt_gsa.lik_only==0,
@@ -115,7 +115,7 @@ for b=1:B
stock_filter = zeros(M_.endo_nbr,gend+1,40);
stock_ys = zeros(40, M_.endo_nbr);
end
- end
+ end
waitbar(b/B,h,['MC smoother ...',num2str(b),'/',num2str(B)]);
end
close(h)
diff --git a/matlab/gsa/stab_map_.m b/matlab/gsa/stab_map_.m
index bdd6f1208..c2fc8c45c 100644
--- a/matlab/gsa/stab_map_.m
+++ b/matlab/gsa/stab_map_.m
@@ -101,12 +101,12 @@ if fload==0,
% if prepSA
% T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),Nsam/2);
% end
-
+
if isfield(dr_,'ghx'),
egg=zeros(length(dr_.eigval),Nsam);
end
yys=zeros(length(dr_.ys),Nsam);
-
+
if opt_gsa.morris == 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;
@@ -129,7 +129,7 @@ if fload==0,
for j=1:np,
lpmat(:,j) = randperm(Nsam)'./(Nsam+1); %latin hypercube
end
-
+
end
end
% try
@@ -220,7 +220,7 @@ if fload==0,
ub=min([bayestopt_.ub(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;
- end
+ end
else
d = chol(inv(hh));
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
iindeterm=iindeterm(find(iindeterm)); % indeterminacy
iwrong=iwrong(find(iwrong)); % dynare could not find solution
-
+
% % map stable samples
% istable=[1:Nsam];
% for j=1:Nsam,
@@ -368,7 +368,7 @@ if fload==0,
'bkpprior','lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ...
'egg','yys','T','nspred','nboth','nfwrd')
end
-
+
else
if ~prepSA
save([OutputDirectoryName '/' fname_ '_mc'], ...
@@ -388,8 +388,8 @@ else
end
load(filetoload,'lpmat','lpmat0','iunstable','istable','iindeterm','iwrong','egg','yys','nspred','nboth','nfwrd')
Nsam = size(lpmat,1);
-
-
+
+
if prepSA & isempty(strmatch('T',who('-file', filetoload),'exact')),
h = waitbar(0,'Please wait...');
options_.periods=0;
@@ -486,7 +486,7 @@ if length(iunstable)>0 & length(iunstable)ksstat);
@@ -500,7 +500,7 @@ if length(iunstable)>0 & length(iunstable)ksstat);
@@ -514,13 +514,13 @@ if length(iunstable)>0 & length(iunstable)10,
stab_map_2(lpmat(iunstable,:),alpha2, pvalue_corr, auname, OutputDirectoryName);
@@ -534,12 +534,12 @@ if length(iunstable)>0 & length(iunstable)10,
stab_map_2(lpmat(iwrong,:),alpha2, pvalue_corr, awrongname, OutputDirectoryName);
end
-
+
x0=0.5.*(bayestopt_.ub(1:nshock)-bayestopt_.lb(1:nshock))+bayestopt_.lb(1:nshock);
x0 = [x0; lpmat(istable(1),:)'];
if istable(end)~=Nsam
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([]);
end
else
@@ -551,7 +551,7 @@ else
disp('All parameter values in the specified ranges are not acceptable!')
x0=[];
end
-
+
end
diff --git a/matlab/osr1.m b/matlab/osr1.m
index 624a623ec..4effeac90 100644
--- a/matlab/osr1.m
+++ b/matlab/osr1.m
@@ -46,7 +46,7 @@ dr = set_state_space(oo_.dr,M_);
if exist([M_.fname '_steadystate'])
[ys,check1] = feval([M_.fname '_steadystate'],oo_.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
ys = add_auxiliary_variables_to_steadystate(ys,M_.aux_vars,...
M_.fname,...
@@ -114,6 +114,6 @@ for i=1:np
end
disp(sprintf('Objective function : %16.6g\n',f));
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
\ No newline at end of file
diff --git a/matlab/osr_obj.m b/matlab/osr_obj.m
index 781eab25b..805e990ae 100644
--- a/matlab/osr_obj.m
+++ b/matlab/osr_obj.m
@@ -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
% along with Dynare. If not, see .
-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_
vx = [];
@@ -27,7 +27,7 @@ M_.params(i_params) = x;
% don't change below until the part where the loss function is computed
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)
case 1
@@ -54,7 +54,7 @@ switch info(1)
otherwise
end
-vx = get_variance_of_endogenous_variables(dr,i_var);
+vx = get_variance_of_endogenous_variables(dr,i_var);
loss = weights(:)'*vx(:);
diff --git a/matlab/perfect_foresight_simulation.m b/matlab/perfect_foresight_simulation.m
index 82adbdc18..2b2b4c4a3 100644
--- a/matlab/perfect_foresight_simulation.m
+++ b/matlab/perfect_foresight_simulation.m
@@ -4,8 +4,8 @@ function info = perfect_foresight_simulation(compute_linear_solution,steady_stat
% INPUTS
% 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.
-% compute_linear_solution [integer] scalar equal to zero or one.
-%
+% compute_linear_solution [integer] scalar equal to zero or one.
+%
% OUTPUTS
% 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
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'];
- ny = size(oo_.endo_simul,1);
+ ny = size(oo_.endo_simul,1);
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;
- nrc = nyf+1;
- iyf = find(lead_lag_incidence(3,:)>0);% indices for leaded variables.
- iyp = find(lead_lag_incidence(1,:)>0);% indices for lagged variables.
+ nrc = nyf+1;
+ iyf = find(lead_lag_incidence(3,:)>0);% indices for leaded variables.
+ iyp = find(lead_lag_incidence(1,:)>0);% indices for lagged variables.
isp = 1:nyp;
- is = (nyp+1):(nyp+ny); % Indices for contemporaneaous variables.
- isf = iyf+nyp;
- isf1 = (nyp+ny+1):(nyf+nyp+ny+1);
+ is = (nyp+1):(nyp+ny); % Indices for contemporaneaous variables.
+ isf = iyf+nyp;
+ isf1 = (nyp+ny+1):(nyf+nyp+ny+1);
iz = 1:(ny+nyp+nyf);
icf = 1:size(iyf,2);
info = [];
@@ -73,8 +73,8 @@ else
end
end
-if ~isstruct(compute_linear_solution) && compute_linear_solution
- [dr,info]=resol(steady_state,0);
+if ~isstruct(compute_linear_solution) && compute_linear_solution
+ [dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
elseif isstruct(compute_linear_solution)
dr = compute_linear_solution;
compute_linear_solution = 1;
@@ -85,22 +85,22 @@ if compute_linear_solution
ghx = ghx(iyf,:);
end
-periods = options_.periods;
+periods = options_.periods;
-stop = 0 ;
-it_init = M_.maximum_lag+1;
+stop = 0 ;
+it_init = M_.maximum_lag+1;
-info.convergence = 1;
-info.time = 0;
-info.error = 0;
-info.iterations.time = zeros(options_.maxit_,1);
-info.iterations.error = info.iterations.time;
+info.convergence = 1;
+info.time = 0;
+info.error = 0;
+info.iterations.time = zeros(options_.maxit_,1);
+info.iterations.error = info.iterations.time;
last_line = options_.maxit_;
error_growth = 0;
h1 = clock;
-for iter = 1:options_.maxit_
+for iter = 1:options_.maxit_
h2 = clock;
if options_.terminal_condition
c = zeros(ny*(periods+1),nrc);
@@ -108,23 +108,23 @@ for iter = 1:options_.maxit_
c = zeros(ny*periods,nrc);
end
it_ = it_init;
- 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_);
- jacobian = [jacobian(:,iz) , -d1];
+ 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_);
+ jacobian = [jacobian(:,iz) , -d1];
ic = 1:ny;
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))
- 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_);
+ 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_);
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;
icp = icp + ny;
- c(ic,:) = jacobian(:,is)\jacobian(:,isf1);
+ c(ic,:) = jacobian(:,is)\jacobian(:,isf1);
end
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(:,isf) = s(:,isf)+c(ic,1:nyf);
ic = ic + ny;
@@ -147,10 +147,10 @@ for iter = 1:options_.maxit_
else% Terminal condition is Y_{T}=Y^{\star}
c = bksup0(c,ny,nrc,iyf,icf,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
- err = max(max(abs(c)));
- info.iterations.time(iter) = etime(clock,h2);
+ err = max(max(abs(c)));
+ info.iterations.time(iter) = etime(clock,h2);
info.iterations.error(iter) = err;
if 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
if err < options_.dynatol
stop = 1;
- info.time = etime(clock,h1);
+ info.time = etime(clock,h1);
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);
break
end
end
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.
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;
diff --git a/matlab/prior_posterior_statistics_core.m b/matlab/prior_posterior_statistics_core.m
index 8dfc1ea0d..9ec608180 100644
--- a/matlab/prior_posterior_statistics_core.m
+++ b/matlab/prior_posterior_statistics_core.m
@@ -162,7 +162,7 @@ for b=fpar:B
end
end
set_all_parameters(deep);
- [dr,info] = resol(oo_.steady_state,0);
+ [dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
if run_smoother
[alphahat,etahat,epsilonhat,alphatilde,SteadyState,trend_coeff,aK] = ...
diff --git a/matlab/prior_sampler.m b/matlab/prior_sampler.m
index fecd806ac..36ba42bdd 100644
--- a/matlab/prior_sampler.m
+++ b/matlab/prior_sampler.m
@@ -2,13 +2,13 @@ function results = prior_sampler(drsave,M_,bayestopt_,options_,oo_)
% This function builds a (big) prior sample.
%
% 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.
-% bayestopt_ [structure] Prior distribution description.
+% bayestopt_ [structure] Prior distribution description.
% options_ [structure] Global options of Dynare.
-%
+%
% OUTPUTS:
-% results [structure] Various statistics.
+% results [structure] Various statistics.
%
% SPECIAL REQUIREMENTS
% none
@@ -80,7 +80,7 @@ while iteration < NumberOfSimulations
loop_indx = loop_indx+1;
params = prior_draw();
set_all_parameters(params);
- [dr,INFO] = resol(oo_.steady_state,work);
+ [dr,INFO,M_,options_,oo_] = resol(work,M_,options_,oo_);
switch INFO(1)
case 0
file_line_number = file_line_number + 1 ;
diff --git a/matlab/resol.m b/matlab/resol.m
index 4d48263f3..ab55d3803 100644
--- a/matlab/resol.m
+++ b/matlab/resol.m
@@ -1,32 +1,80 @@
-function [dr,info]=resol(steady_state_0,check_flag)
-% function [dr,info]=resol(steady_state_0,check_flag)
-% Computes first and second order approximations
-%
-% INPUTS
-% steady_state_0: vector of variables in steady state
-% check_flag=0: all the approximation is computed
-% check_flag=1: computes only the eigenvalues
-%
-% OUTPUTS
-% dr: structure of decision rules for stochastic simulations
-% info=1: the model doesn't determine the current variables '...' uniquely
-% info=2: MJDGGES returns the following error code'
-% info=3: Blanchard Kahn conditions are not satisfied: no stable '...' equilibrium
-% info=4: Blanchard Kahn conditions are not satisfied:'...' indeterminacy
-% info=5: Blanchard Kahn conditions are not satisfied:'...' indeterminacy due to rank failure
-% info=6: The jacobian evaluated at the steady state is complex.
-% info=19: The steadystate file did not compute the steady state (inconsistent deep parameters).
-% info=20: can't find steady state info(2) contains sum of sqare residuals
-% info=21: steady state is complex valued scalars
-% info(2) contains sum of square of
-% imaginary part of steady state
-% info=22: steady state has NaNs
-% info=23: M_.params has been updated in the steady state file and has complex valued scalars.
-% info=24: M_.params has been updated in the steady state file and has some NaNs.
-% info=30: Variance can't be computed
-%
-% SPECIAL REQUIREMENTS
-% none
+function [dr,info,M,options,oo] = resol(check_flag,M,options,oo)
+
+%@info:
+%! @deftypefn {Function File} {[@var{dr},@var{info},@var{M},@var{options},@var{oo}] =} resol (@var{check_flag},@var{M},@var{options},@var{oo})
+%! @anchor{resol}
+%! @sp 1
+%! Computes first and second order reduced form of the DSGE model.
+%! @sp 2
+%! @strong{Inputs}
+%! @sp 1
+%! @table @ @var
+%! @item check_flag
+%! Integer scalar, equal to 0 if all the approximation is required, positive if only the eigenvalues are to be computed.
+%! @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{Outputs}
+%! @sp 1
+%! @table @ @var
+%! @item dr
+%! Matlab's structure describing the reduced form solution of the model.
+%! @item info
+%! Integer scalar, error code.
+%! @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
%
@@ -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
% along with Dynare. If not, see .
-global M_ options_ oo_
global it_
-jacobian_flag = 0;
+jacobian_flag = 0;
-if isfield(oo_,'dr');
- dr = oo_.dr;
+if isfield(oo,'dr');
+ dr = oo.dr;
end
-options_ = set_default_option(options_,'jacobian_flag',1);
+options = set_default_option(options,'jacobian_flag',1);
info = 0;
-it_ = M_.maximum_lag + 1 ;
+it_ = M.maximum_lag + 1 ;
-if M_.exo_nbr == 0
- oo_.exo_steady_state = [] ;
+if M.exo_nbr == 0
+ oo.exo_steady_state = [] ;
end
-params0 = M_.params;
+params0 = M.params;
% check if steady_state_0 is steady state
-tempex = oo_.exo_simul;
-oo_.exo_simul = repmat(oo_.exo_steady_state',M_.maximum_lag+M_.maximum_lead+1,1);
-if M_.exo_det_nbr > 0
- tempexdet = oo_.exo_det_simul;
- oo_.exo_det_simul = repmat(oo_.exo_det_steady_state',M_.maximum_lag+M_.maximum_lead+1,1);
+tempex = oo.exo_simul;
+oo.exo_simul = repmat(oo.exo_steady_state',M.maximum_lag+M.maximum_lead+1,1);
+if M.exo_det_nbr > 0
+ tempexdet = oo.exo_det_simul;
+ oo.exo_det_simul = repmat(oo.exo_det_steady_state',M.maximum_lag+M.maximum_lead+1,1);
end
steady_state = steady_state_0;
check1 = 0;
% testing for steadystate file
-if (~options_.bytecode)
- fh = str2func([M_.fname '_static']);
+if (~options.bytecode)
+ fh = str2func([M.fname '_static']);
end
-if options_.steadystate_flag
- [steady_state,check1] = feval([M_.fname '_steadystate'],steady_state,...
- [oo_.exo_steady_state; ...
- oo_.exo_det_steady_state]);
- if size(steady_state,1) < M_.endo_nbr
- if length(M_.aux_vars) > 0
- steady_state = add_auxiliary_variables_to_steadystate(steady_state,M_.aux_vars,...
- M_.fname,...
- oo_.exo_steady_state,...
- oo_.exo_det_steady_state,...
- M_.params,...
- options_.bytecode);
+if options.steadystate_flag
+ [steady_state,check1] = feval([M.fname '_steadystate'],steady_state,...
+ [oo.exo_steady_state; ...
+ oo.exo_det_steady_state]);
+ if size(steady_state,1) < M.endo_nbr
+ if length(M.aux_vars) > 0
+ steady_state = add_auxiliary_variables_to_steadystate(steady_state,M.aux_vars,...
+ M.fname,...
+ oo.exo_steady_state,...
+ oo.exo_det_steady_state,...
+ M.params,...
+ options.bytecode);
else
- error([M_.fname '_steadystate.m doesn''t match the model']);
+ error([M.fname '_steadystate.m doesn''t match the model']);
end
end
else
% 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_.linear == 0
+ if options.ramsey_policy == 0
+ if options.linear == 0
% nonlinear models
- if (options_.block == 0 && options_.bytecode == 0)
- if max(abs(feval(fh,steady_state,[oo_.exo_steady_state; ...
- oo_.exo_det_steady_state], M_.params))) > options_.dynatol
- [steady_state,check1] = dynare_solve(fh,steady_state,options_.jacobian_flag,...
- [oo_.exo_steady_state; ...
- oo_.exo_det_steady_state], M_.params);
+ if (options.block == 0 && options.bytecode == 0)
+ if max(abs(feval(fh,steady_state,[oo.exo_steady_state; ...
+ oo.exo_det_steady_state], M.params))) > options.dynatol
+ [steady_state,check1] = dynare_solve(fh,steady_state,options.jacobian_flag,...
+ [oo.exo_steady_state; ...
+ oo.exo_det_steady_state], M.params);
end
else
[steady_state,check1] = dynare_solve_block_or_bytecode(steady_state,...
- [oo_.exo_steady_state; ...
- oo_.exo_det_steady_state], M_.params);
+ [oo.exo_steady_state; ...
+ oo.exo_det_steady_state], M.params);
end;
else
- if (options_.block == 0 && options_.bytecode == 0)
+ if (options.block == 0 && options.bytecode == 0)
% linear models
- [fvec,jacob] = feval(fh,steady_state,[oo_.exo_steady_state;...
- oo_.exo_det_steady_state], M_.params);
+ [fvec,jacob] = feval(fh,steady_state,[oo.exo_steady_state;...
+ oo.exo_det_steady_state], M.params);
if max(abs(fvec)) > 1e-12
steady_state = steady_state-jacob\fvec;
end
else
[steady_state,check1] = dynare_solve_block_or_bytecode(steady_state,...
- [oo_.exo_steady_state; ...
- oo_.exo_det_steady_state], M_.params);
+ [oo.exo_steady_state; ...
+ oo.exo_det_steady_state], M.params);
end;
end
end
end
-% test if M_.params_has changed.
-if options_.steadystate_flag
- updated_params_flag = max(abs(M_.params-params0))>1e-12;
+% test if M.params_has changed.
+if options.steadystate_flag
+ updated_params_flag = max(abs(M.params-params0))>1e-12;
else
updated_params_flag = 0;
end
@@ -141,12 +188,12 @@ end
dr.ys = steady_state;
if check1
- if options_.steadystate_flag
+ if options.steadystate_flag
info(1)= 19;
resid = check1 ;
else
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
info(2) = resid'*resid ;
return
@@ -167,14 +214,14 @@ if ~isempty(find(isnan(steady_state)))
return
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(2) = sum(imag(M_.params).^2);
+ info(2) = sum(imag(M.params).^2);
dr.ys = steady_state;
return
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(2) = NaN;
dr.ys = steady_state;
@@ -182,22 +229,17 @@ if options_.steadystate_flag && updated_params_flag && ~isempty(find(isnan(M_.p
end
-if options_.block
- [dr,info,M_,options_,oo_] = dr_block(dr,check_flag,M_,options_,oo_);
+if options.block
+ [dr,info,M,options,oo] = dr_block(dr,check_flag,M,options,oo);
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
if info(1)
return
end
-if M_.exo_det_nbr > 0
- oo_.exo_det_simul = tempexdet;
+if M.exo_det_nbr > 0
+ oo.exo_det_simul = tempexdet;
end
-oo_.exo_simul = 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
+oo.exo_simul = tempex;
+tempex = [];
\ No newline at end of file
diff --git a/matlab/reversed_extended_path.m b/matlab/reversed_extended_path.m
index 877db2574..4a1f6e1cd 100644
--- a/matlab/reversed_extended_path.m
+++ b/matlab/reversed_extended_path.m
@@ -1,17 +1,17 @@
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
% reproduce the time path of a subset of endogenous variables. The initial condition is teh deterministic
-% steady state.
-%
-% INPUTS
-% o controlled_variable_names [string] n*1 matlab's cell.
-% o control_innovation_names [string] n*1 matlab's cell.
+% steady state.
+%
+% INPUTS
+% o controlled_variable_names [string] n*1 matlab's cell.
+% o control_innovation_names [string] n*1 matlab's cell.
% o dataset [structure]
% OUTPUTS
% o innovations [double] n*T matrix.
-%
+%
% ALGORITHM
-%
+%
% SPECIAL REQUIREMENTS
% 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
% along with Dynare. If not, see .
-global M_ oo_ options_
+global M_ oo_ options_
%% Initialization
@@ -48,14 +48,14 @@ steady_;
% Compute the first order perturbation reduced form.
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;
% Set various options.
options_.periods = 100;
% Set-up oo_.exo_simul.
-make_ex_;
+make_ex_;
% Set-up oo_.endo_simul.
make_y_;
@@ -98,13 +98,13 @@ for t=1:T
total_variation = y_target-transpose(oo_.endo_simul(t+M_.maximum_lag,iy));
for i=1:100
[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);
end
if exitflag==1
innovation_paths(:,t) = tmp;
end
% 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;
end
\ No newline at end of file
diff --git a/matlab/selec_posterior_draws.m b/matlab/selec_posterior_draws.m
index 7f7cb0f1d..d1b60fb38 100644
--- a/matlab/selec_posterior_draws.m
+++ b/matlab/selec_posterior_draws.m
@@ -1,24 +1,24 @@
function SampleAddress = selec_posterior_draws(SampleSize,drsize)
% 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
-% 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
-% _mh file cannot be opened twice.
-%
+% _mh file cannot be opened twice.
+%
% INPUTS
% 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
-% o SampleAddress [integer] A (SampleSize*4) array, each line specifies the
-% location of a posterior draw:
+% o SampleAddress [integer] A (SampleSize*4) array, each line specifies the
+% location of a posterior draw:
% Column 2 --> Chain number
-% Column 3 --> (mh) File number
+% Column 3 --> (mh) File number
% Column 4 --> (mh) line number
%
% SPECIAL REQUIREMENTS
% None.
-%
+%
% Copyright (C) 2006-2011 Dynare Team
%
@@ -46,7 +46,7 @@ npar = npar + estim_params_.ncx;
npar = npar + estim_params_.ncn;
npar = npar + estim_params_.np;
-% Select one task:
+% Select one task:
switch nargin
case 1
info = 0;
@@ -62,14 +62,14 @@ switch nargin
error(['selec_posterior_draws:: Unexpected number of input arguments!'])
end
-% Get informations about the mcmc:
+% Get informations about the mcmc:
MhDirectoryName = CheckPath('metropolis');
fname = [ MhDirectoryName '/' M_.fname];
load([ fname '_mh_history.mat']);
FirstMhFile = record.KeepedDraws.FirstMhFile;
-FirstLine = record.KeepedDraws.FirstLine;
-TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
-LastMhFile = TotalNumberOfMhFiles;
+FirstLine = record.KeepedDraws.FirstLine;
+TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
+LastMhFile = TotalNumberOfMhFiles;
TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8);
@@ -87,7 +87,7 @@ for i = 1:SampleSize
MhLineNumber = FirstLine+DrawNumber-1;
else
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;
end
SampleAddress(i,3) = MhFileNumber;
@@ -111,7 +111,7 @@ if info
pdraws(i,1) = {x2(SampleAddress(i,4),:)};
if info-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 };
end
old_mhfile = mhfile;
@@ -121,7 +121,7 @@ if info
save([fname '_posterior_draws1.mat'],'pdraws')
else% The posterior draws are saved in xx files.
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;
linee = 0;
fnum = 1;
@@ -138,7 +138,7 @@ if info
pdraws(linee,1) = {x2(SampleAddress(i,4),:)};
if info-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 };
end
old_mhfile = mhfile;
diff --git a/matlab/stoch_simul.m b/matlab/stoch_simul.m
index 6938107e5..bcd6a1405 100644
--- a/matlab/stoch_simul.m
+++ b/matlab/stoch_simul.m
@@ -69,7 +69,7 @@ elseif options_.discretionary_policy
end
[oo_.dr,ys,info] = discretionary_policy_1(oo_,options_.instruments);
else
- [oo_.dr, info] = resol(oo_.steady_state,0);
+ [oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
end
if info(1)
@@ -137,14 +137,14 @@ if options_.nomoments == 0
if PI_PCL_solver
PCL_Part_info_moments (0, PCL_varobs, oo_.dr, i_var);
elseif options_.periods == 0
- disp_th_moments(oo_.dr,var_list);
+ disp_th_moments(oo_.dr,var_list);
else
disp_moments(oo_.endo_simul,var_list);
end
end
-if options_.irf
+if options_.irf
var_listTeX = M_.endo_names_tex(i_var,:);
if TeX
@@ -169,7 +169,7 @@ if options_.irf
options_.replic, options_.order);
end
if options_.relative_irf
- y = 100*y/cs(i,i);
+ y = 100*y/cs(i,i);
end
irfs = [];
mylist = [];
@@ -180,7 +180,7 @@ if options_.irf
assignin('base',[deblank(M_.endo_names(i_var(j),:)) '_' deblank(M_.exo_names(i,:))],...
y(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
irfs = cat(1,irfs,y(i_var(j),:));
if isempty(mylist)
@@ -280,7 +280,7 @@ if options_.irf
% close(hh);
end
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;
m = m+1;
subplot(lr,lc,m);
@@ -333,4 +333,4 @@ end
options_ = options_old;
% temporary fix waiting for local options
-options_.partial_information = 0;
\ No newline at end of file
+options_.partial_information = 0;
\ No newline at end of file
diff --git a/matlab/stoch_simul_sparse.m b/matlab/stoch_simul_sparse.m
index eefad2ba8..21194408f 100644
--- a/matlab/stoch_simul_sparse.m
+++ b/matlab/stoch_simul_sparse.m
@@ -38,13 +38,13 @@ end
check_model;
-[oo_.dr, info] = resol(oo_.steady_state,0);
+[oo_.dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
if info(1)
options_ = options_old;
print_info(info, options_.noprint);
return
-end
+end
oo_dr_kstate = [];
oo_dr_nstatic = 0;
@@ -74,7 +74,7 @@ if ~options_.noprint
end
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
if options_.periods < options_.drop
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
var_list = M_.endo_names(1:M_.orig_endo_nbr, :);
if TeX
@@ -138,7 +138,7 @@ if options_.irf
y=irf(oo_.dr,cs(M_.exo_names_orig_ord,i), options_.irf, options_.drop, ...
options_.replic, options_.order);
if options_.relative_irf
- y = 100*y/cs(i,i);
+ y = 100*y/cs(i,i);
end
irfs = [];
mylist = [];
@@ -149,7 +149,7 @@ if options_.irf
assignin('base',[deblank(M_.endo_names(ivar(j),:)) '_' deblank(M_.exo_names(i,:))],...
y(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
irfs = cat(1,irfs,y(ivar(j),:));
if isempty(mylist)
@@ -249,7 +249,7 @@ if options_.irf
% close(hh);
end
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;
m = m+1;
subplot(lr,lc,m);