File size: 2,274 Bytes
ed7d493
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
%-------------------------------------------
% 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