Commit 013c599e authored by Stéphane Adjemian's avatar Stéphane Adjemian
Browse files

Removed globals from dynare_resolve. Removed unused first input argument....

Removed globals from dynare_resolve. Removed unused first input argument. Adapted routines calling dynare_resolve.
Added texinfo header to dynare_resolve.
parent b1d87ece
...@@ -125,7 +125,7 @@ M_.H = H; ...@@ -125,7 +125,7 @@ M_.H = H;
%------------------------------------------------------------------------------ %------------------------------------------------------------------------------
% 2. call model setup & reduction program % 2. call model setup & reduction program
%------------------------------------------------------------------------------ %------------------------------------------------------------------------------
[T,R,SteadyState,info] = dynare_resolve('restrict'); [T,R,SteadyState,info,M_,options_,oo_] = dynare_resolve(M_,otions_,oo_);
if info(1) == 1 || info(1) == 2 || info(1) == 5 if info(1) == 1 || info(1) == 2 || info(1) == 5
fval = bayestopt_.penalty+1; fval = bayestopt_.penalty+1;
cost_flag = 0; cost_flag = 0;
......
...@@ -69,8 +69,7 @@ set_all_parameters(xparam1); ...@@ -69,8 +69,7 @@ set_all_parameters(xparam1);
%------------------------------------------------------------------------------ %------------------------------------------------------------------------------
oo_.dr.restrict_var_list = bayestopt_.smoother_var_list; oo_.dr.restrict_var_list = bayestopt_.smoother_var_list;
oo_.dr.restrict_columns = bayestopt_.smoother_restrict_columns; oo_.dr.restrict_columns = bayestopt_.smoother_restrict_columns;
[T,R,SteadyState] = dynare_resolve('restrict'); [T,R,SteadyState,info,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
bayestopt_.mf = bayestopt_.smoother_mf; bayestopt_.mf = bayestopt_.smoother_mf;
if options_.noconstant if options_.noconstant
constant = zeros(nobs,1); constant = zeros(nobs,1);
......
...@@ -34,7 +34,7 @@ function [fval,cost_flag,info,PHI,SIGMAu,iXX,prior] = DsgeVarLikelihood(xparam1, ...@@ -34,7 +34,7 @@ function [fval,cost_flag,info,PHI,SIGMAu,iXX,prior] = DsgeVarLikelihood(xparam1,
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>. % along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global bayestopt_ estim_params_ M_ options_ global bayestopt_ estim_params_ M_ options_ oo_
nvx = estim_params_.nvx; nvx = estim_params_.nvx;
nvn = estim_params_.nvn; nvn = estim_params_.nvn;
...@@ -106,7 +106,7 @@ end ...@@ -106,7 +106,7 @@ end
%------------------------------------------------------------------------------ %------------------------------------------------------------------------------
% 2. call model setup & reduction program % 2. call model setup & reduction program
%------------------------------------------------------------------------------ %------------------------------------------------------------------------------
[T,R,SteadyState,info] = dynare_resolve('restrict'); [T,R,SteadyState,info,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
if info(1) == 1 || info(1) == 2 || info(1) == 5 if info(1) == 1 || info(1) == 2 || info(1) == 5
fval = bayestopt_.penalty+1; fval = bayestopt_.penalty+1;
......
...@@ -124,7 +124,7 @@ M_.H = H; ...@@ -124,7 +124,7 @@ M_.H = H;
%------------------------------------------------------------------------------ %------------------------------------------------------------------------------
% 2. call model setup & reduction program % 2. call model setup & reduction program
%------------------------------------------------------------------------------ %------------------------------------------------------------------------------
[T,R,SteadyState,info] = dynare_resolve('restrict'); [T,R,SteadyState,info,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
if info(1) == 1 || info(1) == 2 || info(1) == 5 if info(1) == 1 || info(1) == 2 || info(1) == 5
fval = bayestopt_.penalty+1; fval = bayestopt_.penalty+1;
cost_flag = 0; cost_flag = 0;
......
function [A,B,ys,info] = dynare_resolve(mode) function [A,B,ys,info,Model,DynareOptions,DynareResults] = dynare_resolve(Model,DynareOptions,DynareResults)
% function [A,B,ys,info] = dynare_resolve(mode) % Computes the linear approximation and the matrices A and B of the transition equation.
% Computes the linear approximation and the matrices A and B of the
% transition equation
%
% INPUTS
% mode: string 'restrict' returns restricted transition matrices
%
% OUTPUTS
% A: matrix of predetermined variables effects in linear solution (ghx)
% B: matrix of shocks effects in linear solution (ghu)
% ys: steady state of original endogenous variables
% 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=20: can't find steady state info(2) contains sum of sqare residuals
% info=30: variance can't be computed
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2003-2011 Dynare Team %@info:
%! @deftypefn {Function File} {[@var{A},@var{B},@var{ys},@var{info},@var{Model},@var{DynareOptions},@var{DynareResults}] =} resol (@var{Model},@var{DynareOptions},@var{DynareResults})
%! @anchor{dynare_resolve}
%! @sp 1
%! Computes the linear approximation and the matrices A and B of the transition equation.
%! @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 Model
%! Matlab's structure describing the model (initialized by dynare, see @ref{M_}).
%! @item DynareOptions
%! Matlab's structure describing the options (initialized by dynare, see @ref{options_}).
%! @item DynareResults
%! Matlab's structure gathering the results (initialized by dynare, see @ref{oo_}).
%! @end table
%! @sp 2
%! @strong{Outputs}
%! @sp 1
%! @table @ @var
%! @item A
%! Matrix of doubles, transition matrix of the state equation.
%! @item B
%! Matrix of doubles, matrix relating the endogenous variables to the innovations in the state equation.
%! @item ys
%! Vector of doubles, steady state level of the endogenous variables in the state equation.
%! @item info
%! Integer scalar, error code as given by @ref{resol}.
%! @item Model
%! Matlab's structure describing the model (initialized by dynare, see @ref{M_}).
%! @item DynareOptions
%! Matlab's structure describing the options (initialized by dynare, see @ref{options_}).
%! @item DynareResults
%! Matlab's structure gathering the results (initialized by dynare, see @ref{oo_}).
%! @end table
%! @sp 2
%! @strong{This function is called by:}
%! @sp 1
%! @ref{DsgeLikelihood}, @ref{DsgeLikelihood_hh}, @ref{DsgeVarLikelihood}, @ref{dsge_posterior_kernel}, @ref{DsgeSmoother}, @ref{dynare_sensitivity}, @ref{gsa/thet2tau}, @ref{gsa/stab_map}, @ref{identification_analysis}, @ref{imcforecast}, @ref{thet2tau}
%! @sp 2
%! @strong{This function calls:}
%! @sp 1
%! @ref{resol}, @ref{kalman_transition_matrix}
%! @end deftypefn
%@eod:
% Copyright (C) 2001-2011 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -38,10 +66,8 @@ function [A,B,ys,info] = dynare_resolve(mode) ...@@ -38,10 +66,8 @@ 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_ options_ [dr,info,Model,DynareOptions,DynareResults] = resol(0,Model,DynareOptions,DynareResults);
DynareResults.dr = dr;
[dr,info,M_,options_,oo_] = resol(0,M_,options_,oo_);
oo_.dr = dr;
if info(1) > 0 if info(1) > 0
A = []; A = [];
...@@ -55,20 +81,20 @@ if info(1) > 0 ...@@ -55,20 +81,20 @@ if info(1) > 0
end end
if nargin == 0 if nargin == 0
endo_nbr = M_.endo_nbr; endo_nbr = Model.endo_nbr;
nstatic = oo_.dr.nstatic; nstatic = DynareResults.dr.nstatic;
npred = oo_.dr.npred; npred = DynareResults.dr.npred;
iv = (1:endo_nbr)'; iv = (1:endo_nbr)';
ic = [ nstatic+(1:npred) endo_nbr+(1:size(oo_.dr.ghx,2)-npred) ]'; ic = [ nstatic+(1:npred) endo_nbr+(1:size(DynareResults.dr.ghx,2)-npred) ]';
else else
iv = oo_.dr.restrict_var_list; iv = DynareResults.dr.restrict_var_list;
ic = oo_.dr.restrict_columns; ic = DynareResults.dr.restrict_columns;
end end
if nargout==1 if nargout==1
A = kalman_transition_matrix(oo_.dr,iv,ic,M_.exo_nbr); A = kalman_transition_matrix(DynareResults.dr,iv,ic,Model.exo_nbr);
return return
end end
[A,B] = kalman_transition_matrix(oo_.dr,iv,ic,M_.exo_nbr); [A,B] = kalman_transition_matrix(DynareResults.dr,iv,ic,Model.exo_nbr);
ys = oo_.dr.ys; ys = DynareResults.dr.ys;
\ No newline at end of file \ No newline at end of file
...@@ -64,7 +64,7 @@ else ...@@ -64,7 +64,7 @@ else
options_.qz_criterium = 1+1e-6; options_.qz_criterium = 1+1e-6;
end end
end end
dynare_resolve; [make,my,day,punk,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
options_gsa = set_default_option(options_gsa,'identification',0); options_gsa = set_default_option(options_gsa,'identification',0);
if options_gsa.identification, if options_gsa.identification,
......
...@@ -247,7 +247,7 @@ if fload==0, ...@@ -247,7 +247,7 @@ if fload==0,
M_.params(estim_params_.param_vals(:,1)) = lpmat(j,:)'; M_.params(estim_params_.param_vals(:,1)) = lpmat(j,:)';
%try stoch_simul([]); %try stoch_simul([]);
try try
[Tt,Rr,SteadyState,infox{j}] = dynare_resolve('restrict'); [Tt,Rr,SteadyState,infox{j},M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
if infox{j}(1)==0 && ~exist('T'), if infox{j}(1)==0 && ~exist('T'),
dr_=oo_.dr; dr_=oo_.dr;
T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),Nsam); T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),Nsam);
...@@ -402,9 +402,11 @@ else ...@@ -402,9 +402,11 @@ else
for j=1:ntrans, for j=1:ntrans,
M_.params(estim_params_.param_vals(:,1)) = lpmat(istable(j),:)'; M_.params(estim_params_.param_vals(:,1)) = lpmat(istable(j),:)';
%stoch_simul([]); %stoch_simul([]);
[Tt,Rr,SteadyState,info] = dynare_resolve(bayestopt_.restrict_var_list,... [Tt,Rr,SteadyState,info,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
bayestopt_.restrict_columns,... % This syntax is not compatible with the current version of dynare_resolve [stepan].
bayestopt_.restrict_aux); %[Tt,Rr,SteadyState,info] = dynare_resolve(bayestopt_.restrict_var_list,...
% bayestopt_.restrict_columns,...
% bayestopt_.restrict_aux);
if ~exist('T') if ~exist('T')
T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),ntrans); T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),ntrans);
end end
......
...@@ -18,7 +18,7 @@ if ~isempty(indexo) ...@@ -18,7 +18,7 @@ if ~isempty(indexo)
M_.Sigma_e(indexo,indexo) = diag(params(1:length(indexo)).^2); M_.Sigma_e(indexo,indexo) = diag(params(1:length(indexo)).^2);
end end
% [A(oo_.dr.order_var,oo_.dr.order_var),B(oo_.dr.order_var,:)]=dynare_resolve; % [A(oo_.dr.order_var,oo_.dr.order_var),B(oo_.dr.order_var,:)]=dynare_resolve;
[A,B]=dynare_resolve; [A,B,plouf,plouf,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
if flagmoments==0, if flagmoments==0,
tau = [oo_.dr.ys(oo_.dr.order_var); A(:); dyn_vech(B*M_.Sigma_e*B')]; tau = [oo_.dr.ys(oo_.dr.order_var); A(:); dyn_vech(B*M_.Sigma_e*B')];
else else
......
...@@ -65,7 +65,7 @@ ide_model = struct(); ...@@ -65,7 +65,7 @@ ide_model = struct();
ide_lre = struct(); ide_lre = struct();
derivatives_info = struct(); derivatives_info = struct();
[A,B,ys,info]=dynare_resolve; [A,B,ys,info,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
if info(1)==0, if info(1)==0,
oo0=oo_; oo0=oo_;
tau=[oo_.dr.ys(oo_.dr.order_var); vec(A); dyn_vech(B*M_.Sigma_e*B')]; tau=[oo_.dr.ys(oo_.dr.order_var); vec(A); dyn_vech(B*M_.Sigma_e*B')];
......
...@@ -155,7 +155,7 @@ end ...@@ -155,7 +155,7 @@ end
if isempty(options_.qz_criterium) if isempty(options_.qz_criterium)
options_.qz_criterium = 1+1e-6; options_.qz_criterium = 1+1e-6;
end end
[T,R,ys,info] = dynare_resolve; [T,R,ys,info,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
sQ = sqrt(M_.Sigma_e); sQ = sqrt(M_.Sigma_e);
......
...@@ -37,7 +37,7 @@ if ~isempty(indexo) ...@@ -37,7 +37,7 @@ if ~isempty(indexo)
M_.Sigma_e(indexo,indexo) = diag(params(1:length(indexo)).^2); M_.Sigma_e(indexo,indexo) = diag(params(1:length(indexo)).^2);
end end
% [A(oo_.dr.order_var,oo_.dr.order_var),B(oo_.dr.order_var,:)]=dynare_resolve; % [A(oo_.dr.order_var,oo_.dr.order_var),B(oo_.dr.order_var,:)]=dynare_resolve;
[A,B]=dynare_resolve; [A,B,tele,tubbies,M_,options_,oo_] = dynare_resolve(M_,options_,oo_);
if flagmoments==0, if flagmoments==0,
tau = [oo_.dr.ys(oo_.dr.order_var); A(:); dyn_vech(B*M_.Sigma_e*B')]; tau = [oo_.dr.ys(oo_.dr.order_var); A(:); dyn_vech(B*M_.Sigma_e*B')];
else else
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment