%-------------------------------------------
% RBC model with Markov-switching parameters
%-------------------------------------------
% The parameters that depend on the regime are the discount
% factor and the depreciation rate.
% There are 2 regimes.
clear,clc
%-----------------------------------------
% Define symbolic variables and parameters
%-----------------------------------------
syms k kp c cp z zp epsp real
syms BETA BETAp GAMMA ALPHA RHO DELTA DELTAp SIGMA real
%-----------------------------
% Function f (Euler condition)
%-----------------------------
f_fun=BETA*(c/cp)^GAMMA*(ALPHA*exp(zp)*kp^(ALPHA-1)+1-DELTAp)-1; % note the use of future depreciation rate DELTAp
%-------------------------------------------------------
% Function Phi (law of motion of capital and technology)
%-------------------------------------------------------
Phi_fun=[exp(z)*k^ALPHA+(1-DELTA)*k-c; % here we use the current depreciation rate DELTA
RHO*z+SIGMA*epsp];
%--------------------------
% Vector of state variables
%--------------------------
x=[k,z]; % current period
xp=[kp,zp]; % future period
%----------------------------
% Vector of control variables
%----------------------------
y=[c]; % current period
yp=[cp]; % future period
%-----------------
% Vector of shocks
%-----------------
shocks=[epsp];
%---------------------------
% Vector of fixed parameters
%---------------------------
symparams=[GAMMA,ALPHA,RHO,SIGMA];
%--------------------------------------
% Vector of Markov-switching parameters
%--------------------------------------
chi=[BETA,DELTA]; % current period
chip=[BETAp,DELTAp]; % next period
%--------------------
% Approximation order
%--------------------
order=4; % fourth order is the maximum possible
%------------------
% number of regimes
%------------------
n_regimes=2;
%----------------
% Call prepare_tp
%----------------
model=prepare_tp(f_fun,Phi_fun,yp,y,xp,x,shocks,chip,chi,symparams,order,n_regimes);
% % if you use auxiliary functions and variables, use the following syntax:
% model=prepare_tp(f_fun,Phi_fun,yp,y,xp,x,shocks,chip,chi,symparams,order,n_regimes,auxfuns,auxvars);
save('model') % you will need this later