Commit 24cd4236 authored by Stéphane Adjemian's avatar Stéphane Adjemian

Removed globals from resol.m (changed calling sequence). Added texinfo header.

Removed trailing whitespace.
parent d81fd1b5
......@@ -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;
......
......@@ -150,7 +150,7 @@ while fpar<npar
end
stock_param(irun2,:) = deep;
set_parameters(deep);
[dr,info] = resol(oo_.steady_state,0);
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
if info(1)
nosaddle = nosaddle + 1;
fpar = fpar - 1;
......
......@@ -2,8 +2,8 @@ function [nvar,vartan,NumberOfConditionalDecompFiles] = ...
dsge_simulated_theoretical_conditional_variance_decomposition(SampleSize,Steps,M_,options_,oo_,type)
% This function computes the posterior or prior distribution of the conditional variance
% decomposition of the endogenous variables (or a subset of the endogenous variables).
%
% INPUTS
%
% INPUTS
% SampleSize [integer] scalar, number of simulations.
% M_ [structure] Dynare structure describing the model.
% options_ [structure] Dynare structure defining global options.
......@@ -11,7 +11,7 @@ function [nvar,vartan,NumberOfConditionalDecompFiles] = ...
% type [string] 'prior' or 'posterior'
%
%
% OUTPUTS
% OUTPUTS
% nvar [integer] nvar is the number of stationary variables.
% vartan [char] array of characters (with nvar rows).
% NumberOfConditionalDecompFiles [integer] scalar, number of prior or posterior data files (for covariance).
......@@ -103,7 +103,7 @@ for file = 1:NumberOfDrawsFiles
dr = pdraws{linee,2};
else
set_parameters(pdraws{linee,1});
[dr,info] = resol(oo_.steady_state,0);
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
end
if first_call
endo_nbr = M_.endo_nbr;
......
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
% variables second order moments.
%
% INPUTS
% variables second order moments.
%
% INPUTS
% SampleSize [integer]
% nar [integer]
% nar [integer]
% M_ [structure]
% options_ [structure]
% oo_ [structure]
% type [string]
%
% OUTPUTS
% OUTPUTS
% nvar [integer]
% vartan [char]
% CorrFileNumber [integer]
......@@ -98,7 +98,7 @@ for file = 1:NumberOfDrawsFiles
dr = pdraws{linee,2};
else
set_parameters(pdraws{linee,1});
[dr,info] = resol(oo_.steady_state,0);
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
end
tmp = th_autocovariances(dr,ivar,M_,options_,nodecomposition);
for i=1:nar
......
function [nvar,vartan,CovarFileNumber] = dsge_simulated_theoretical_covariance(SampleSize,M_,options_,oo_,type)
% This function computes the posterior or prior distribution of the endogenous
% variables second order moments.
%
% INPUTS
% variables second order moments.
%
% INPUTS
% SampleSize [integer] scalar, number of simulations.
% M_ [structure] Dynare structure describing the model.
% 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'
%
%
% OUTPUTS
% OUTPUTS
% nvar [integer] nvar is the number of stationary variables.
% vartan [char] array of characters (with nvar rows).
% CovarFileNumber [integer] scalar, number of prior or posterior data files (for covariance).
......@@ -98,7 +98,7 @@ for file = 1:NumberOfDrawsFiles
dr = pdraws{linee,2};
else
set_parameters(pdraws{linee,1});
[dr,info] = resol(oo_.steady_state,0);
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
end
tmp = th_autocovariances(dr,ivar,M_,options_,nodecomposition);
for i=1:nvar
......
......@@ -2,8 +2,8 @@ function [nvar,vartan,NumberOfDecompFiles] = ...
dsge_simulated_theoretical_variance_decomposition(SampleSize,M_,options_,oo_,type)
% This function computes the posterior or prior distribution of the variance
% decomposition of the observed endogenous variables.
%
% INPUTS
%
% INPUTS
% SampleSize [integer] scalar, number of simulations.
% M_ [structure] Dynare structure describing the model.
% options_ [structure] Dynare structure defining global options.
......@@ -11,7 +11,7 @@ function [nvar,vartan,NumberOfDecompFiles] = ...
% type [string] 'prior' or 'posterior'
%
%
% OUTPUTS
% OUTPUTS
% nvar [integer] nvar is the number of stationary variables.
% vartan [char] array of characters (with nvar rows).
% CovarFileNumber [integer] scalar, number of prior or posterior data files (for covariance).
......@@ -39,7 +39,7 @@ nodecomposition = 0;
if strcmpi(type,'posterior')
DrawsFiles = dir([M_.dname '/metropolis/' M_.fname '_' type '_draws*' ]);
posterior = 1;
elseif strcmpi(type,'prior')
elseif strcmpi(type,'prior')
DrawsFiles = dir([M_.dname '/prior/draws/' type '_draws*' ]);
CheckPath('prior/moments');
posterior = 0;
......@@ -66,7 +66,7 @@ nvar = length(ivar);
% Set the size of the auto-correlation function to zero.
nar = options_.ar;
options_.ar = 0;
options_.ar = 0;
......@@ -105,7 +105,7 @@ for file = 1:NumberOfDrawsFiles
dr = pdraws{linee,2};
else
set_parameters(pdraws{linee,1});
[dr,info] = resol(oo_.steady_state,0);
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
end
tmp = th_autocovariances(dr,ivar,M_,options_,nodecomposition);
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
% 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
A = [];
......
......@@ -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)
......
......@@ -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)
......
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 <http://www.gnu.org/licenses/>.
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
......@@ -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
......@@ -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)
......
......@@ -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)<Nsam,
stab_map_1(lpmat, [1:Nsam], iindeterm, [aname, '_indet'], 1, indindet, OutputDirectoryName);
end
end
if ~isempty(ixun),
[proba, dproba] = stab_map_1(lpmat, [1:Nsam], ixun, [aname, '_unst'],0);
% 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);
end
end
if ~isempty(iwrong),
[proba, dproba] = stab_map_1(lpmat, [1:Nsam], iwrong, [aname, '_wrong'],0);
% 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);
end
end
disp(' ')
disp('Starting bivariate analysis:')
c0=corrcoef(lpmat(istable,:));
c00=tril(c0,-1);
stab_map_2(lpmat(istable,:),alpha2, pvalue_corr, asname, OutputDirectoryName);
if length(iunstable)>10,
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,
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
......
......@@ -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
......@@ -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 <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_
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(:);
......
......@@ -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;
<