diff --git a/matlab/+occbin/dynare_resolve.m b/matlab/+occbin/dynare_resolve.m index 6c704854220ee64c21196f09171f7a121d99e6e0..5d2bbc825bbde7c7c1b2daace7e6d1fec3672da5 100644 --- a/matlab/+occbin/dynare_resolve.m +++ b/matlab/+occbin/dynare_resolve.m @@ -1,14 +1,17 @@ function [A,B,ys,info,dr,params,TT, RR, CC, A0, B0] ... - = dynare_resolve(M_,options_,oo_,regime_history, reduced_state_space, A, B) -% function [A,B,ys,info,M_,options_,oo_,TT, RR, CC, A0, B0] ... -% = dynare_resolve(M_,options_,oo_,regime_history, reduced_state_space, A, B) + = dynare_resolve(M_,options_,dr,endo_steady_state,exo_steady_state,exo_det_steady_state,regime_history, reduced_state_space, A, B) +% [A,B,ys,info,M_,options_,oo_,TT, RR, CC, A0, B0] ... +% = dynare_resolve(M_,options_,dr,endo_steady_state,exo_steady_state,exo_det_steady_state,regime_history, reduced_state_space, A, B) % Computes the linear approximation and the matrices A and B of the % transition equation. Mirrors dynare_resolve % % Inputs: % - M_ [structure] Matlab's structure describing the model % - options_ [structure] Matlab's structure containing the options -% - oo_ [structure] Matlab's structure containing the results +% - dr [structure] Reduced form model. +% - endo_steady_state [vector] steady state value for endogenous variables +% - exo_steady_state [vector] steady state value for exogenous variables +% - exo_det_steady_state [vector] steady state value for exogenous deterministic variables % - reduced_state_space [string] % - A [double] State transition matrix % - B [double] shock impact matrix @@ -26,7 +29,7 @@ function [A,B,ys,info,dr,params,TT, RR, CC, A0, B0] ... % - A0 [double] State transition matrix (unrestricted state space) % - B0 [double] shock impact matrix (unrestricted state space) -% Copyright © 2001-2021 Dynare Team +% Copyright © 2001-2023 Dynare Team % % This file is part of Dynare. % @@ -43,19 +46,18 @@ function [A,B,ys,info,dr,params,TT, RR, CC, A0, B0] ... % You should have received a copy of the GNU General Public License % along with Dynare. If not, see <https://www.gnu.org/licenses/>. -if nargin<6 - [A,B,ys,info,dr,M_.params] = dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state); +if nargin<9 + [A,B,ys,info,dr,M_.params] = dynare_resolve(M_,options_,dr,endo_steady_state,exo_steady_state,exo_det_steady_state); else - ys = oo_.dr.ys; - dr = oo_.dr; + ys = dr.ys; info = 0; end params=M_.params; -if ~info(1) && nargin>4 && ~isempty(regime_history) +if ~info(1) && nargin>7 && ~isempty(regime_history) opts_regime.regime_history=regime_history; opts_regime.binding_indicator=[]; [TT, RR, CC] = ... - occbin.check_regimes(A, B, [], opts_regime, M_, options_, dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state); + occbin.check_regimes(A, B, [], opts_regime, M_, options_, dr, endo_steady_state, exo_steady_state, exo_det_steady_state); else TT=A; RR=B; @@ -64,7 +66,7 @@ end A0=A; B0=B; -if ~info(1) && nargin>4 && ischar(reduced_state_space) && ~isempty(reduced_state_space) +if ~info(1) && nargin>7 && ischar(reduced_state_space) && ~isempty(reduced_state_space) iv = dr.restrict_var_list; A=A(iv,iv); B=B(iv,:); diff --git a/matlab/+occbin/kalman_update_algo_1.m b/matlab/+occbin/kalman_update_algo_1.m index 2f304308665663fafb6afd81fe0cb7b7b5a237f3..b0318e7f4ab040056c8ef482033ded0ef194b2de 100644 --- a/matlab/+occbin/kalman_update_algo_1.m +++ b/matlab/+occbin/kalman_update_algo_1.m @@ -104,7 +104,7 @@ if ~options_.occbin.filter.use_relaxation [a, a1, P, P1, v, alphahat, etahat, lik, error_flag] = occbin_kalman_update0(a,a1,P,P1,data_index,Z,v,Y,H,QQQ,TT,RR,CC,iF,L,mm, options_.rescale_prediction_error_covariance, options_.occbin.likelihood.IF_likelihood); else [~,~,~,~,~,~, TTx, RRx, CCx] ... - = occbin.dynare_resolve(M_,options_,oo_, base_regime,'reduced_state_space',T0,R0); + = occbin.dynare_resolve(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state, base_regime,'reduced_state_space',T0,R0); regimes0(1)=base_regime; TT(:,:,2) = TTx(:,:,end); RR(:,:,2) = RRx(:,:,end); @@ -188,7 +188,7 @@ if any(myregime) || ~isequal(regimes_(1),regimes0(1)) end regimes_(1).regimestart(end)=regimestart; [~,~,~,~,~,~, TTx, RRx, CCx] ... - = occbin.dynare_resolve(M_,options_,oo_, [base_regime regimes_(1)],'reduced_state_space', T0, R0); + = occbin.dynare_resolve(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state, [base_regime regimes_(1)],'reduced_state_space', T0, R0); TT(:,:,2) = TTx(:,:,end); RR(:,:,2) = RRx(:,:,end); CC(:,2) = CCx(:,end); @@ -254,7 +254,7 @@ if any(myregime) || ~isequal(regimes_(1),regimes0(1)) regimes_(1).regimestart=[1 2]; end [~,~,~,~,~,~, TTx, RRx, CCx] ... - = occbin.dynare_resolve(M_,options_,oo_, [base_regime regimes_(1)],'reduced_state_space',T0,R0); + = occbin.dynare_resolve(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state, [base_regime regimes_(1)],'reduced_state_space',T0,R0); TT(:,:,2) = TTx(:,:,end); RR(:,:,2) = RRx(:,:,end); CC(:,2) = CCx(:,end); @@ -307,7 +307,7 @@ if ~error_flag && niter>options_.occbin.likelihood.max_number_of_iterations && ~ regimes_(1).regimestart(end)=k; [~,~,~,~,~,~, TTx, RRx, CCx] ... - = occbin.dynare_resolve(M_,options_,oo_, [base_regime regimes_(1)],'reduced_state_space',T0,R0); + = occbin.dynare_resolve(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state, [base_regime regimes_(1)],'reduced_state_space',T0,R0); TT(:,:,2) = TTx(:,:,end); RR(:,:,2) = RRx(:,:,end); CC(:,2) = CCx(:,end); diff --git a/matlab/+occbin/kalman_update_algo_3.m b/matlab/+occbin/kalman_update_algo_3.m index c370920e239e756ac0ddbe980692cda9a1c5a1a7..3fdfa7bb7ed75b8f8050c9ec74d9e459f71a3302 100644 --- a/matlab/+occbin/kalman_update_algo_3.m +++ b/matlab/+occbin/kalman_update_algo_3.m @@ -104,7 +104,7 @@ if ~options_.occbin.filter.use_relaxation [a, a1, P, P1, v, Fi, Ki, alphahat, etahat] = occbin_kalman_update(a,a1,P,P1,data_index,Z,v,Y,H,QQQ,TT,RR,CC,Ki,Fi,mm,kalman_tol); else [~,~,~,~,~,~, TTx, RRx, CCx] ... - = occbin.dynare_resolve(M_,options_,oo_, base_regime,myrestrict,T0,R0); + = occbin.dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state, base_regime,myrestrict,T0,R0); TT(:,:,2) = TTx(:,:,end); RR(:,:,2) = RRx(:,:,end); CC(:,2) = CCx(:,end); @@ -183,7 +183,7 @@ if any(myregime) || ~isequal(regimes_(1),regimes0(1)) % % % regimestart = regimes_(1).regimestart(end-1)+round(0.5*(newstart+oldstart))-1; regimes_(1).regimestart(end)=regimestart; [~,~,~,~,~,~, TTx, RRx, CCx] ... - = occbin.dynare_resolve(M_,options_,oo_, [base_regime regimes_(1)],myrestrict,T0,R0); + = occbin.dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state, [base_regime regimes_(1)],myrestrict,T0,R0); TT(:,:,2) = TTx(:,:,end); RR(:,:,2) = RRx(:,:,end); CC(:,2) = CCx(:,end); @@ -252,7 +252,7 @@ if any(myregime) || ~isequal(regimes_(1),regimes0(1)) regimes_(1).regimestart=[1 2]; end [~,~,~,~,~,~, TTx, RRx, CCx] ... - = occbin.dynare_resolve(M_,options_,oo_, [base_regime regimes_(1)],myrestrict,T0,R0); + = occbin.dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state, [base_regime regimes_(1)],myrestrict,T0,R0); TT(:,:,2) = TTx(:,:,end); RR(:,:,2) = RRx(:,:,end); CC(:,2) = CCx(:,end); @@ -301,7 +301,7 @@ if error_flag==0 && niter>options_.occbin.likelihood.max_number_of_iterations && regimes_(1).regimestart(end)=k; [~,~,~,~,~,~, TTx, RRx, CCx] ... - = occbin.dynare_resolve(M_,options_,oo_, [base_regime regimes_(1)],myrestrict,T0,R0); + = occbin.dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state, [base_regime regimes_(1)],myrestrict,T0,R0); TT(:,:,2) = TTx(:,:,end); RR(:,:,2) = RRx(:,:,end); CC(:,2) = CCx(:,end); diff --git a/matlab/DsgeSmoother.m b/matlab/DsgeSmoother.m index 109ad465820990bfb38ebe4abd516b8011fdd374..df5f9f931246a491e1826867fb0194a44f1e0c47 100644 --- a/matlab/DsgeSmoother.m +++ b/matlab/DsgeSmoother.m @@ -115,7 +115,7 @@ else [T,R,SteadyState,info,oo_.dr,M_.params] = dynare_resolve(M_,options_,oo_.dr,oo_.steady_state,oo_.exo_steady_state,oo_.exo_det_steady_state,'restrict'); else [T,R,SteadyState,info,oo_.dr, M_.params,~,~,~, T0, R0] = ... - occbin.dynare_resolve(M_,options_,oo_,[],'restrict'); + occbin.dynare_resolve(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state,[],'restrict'); varargin{length_varargin+1}=T0; varargin{length_varargin+2}=R0; end diff --git a/matlab/dsge_likelihood.m b/matlab/dsge_likelihood.m index 32cf4a3409e1ee6ed04128eab62041ae31dbd25b..ce4b2cae13efb60121405cdbb286c565612a9554 100644 --- a/matlab/dsge_likelihood.m +++ b/matlab/dsge_likelihood.m @@ -194,7 +194,7 @@ if options_.occbin.likelihood.status occbin_options = set_occbin_options(options_, M_); if occbin_options.opts_simul.restrict_state_space [T,R,SteadyState,info,oo_.dr, M_.params,TTx,RRx,CCx, T0, R0] = ... - occbin.dynare_resolve(M_,options_,oo_,[],'restrict'); + occbin.dynare_resolve(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state,[],'restrict'); else is_restrict_state_space = false; oldoo.restrict_var_list = oo_.dr.restrict_var_list; @@ -204,7 +204,7 @@ if options_.occbin.likelihood.status % Linearize the model around the deterministic steady state and extract the matrices of the state equation (T and R). [T,R,SteadyState,info,M_,oo_.dr, M_.params,TTx,RRx,CCx, T0, R0] = ... - occbin.dynare_resolve(M_,options_,oo_); + occbin.dynare_resolve(M_,options_,oo_.dr, oo_.steady_state, oo_.exo_steady_state, oo_.exo_det_steady_state); oo_.dr.restrict_var_list = oldoo.restrict_var_list; oo_.dr.restrict_columns = oldoo.restrict_columns;