To write an RBC (Real Business Cycle) model in Matlab, we need to follow these steps:
Household optimization problem:
\begin{aligned}
V(k_t,z_t,\epsilon_t)&=\max_{c_t,k_{t+1}}E_{t}\sum_{n=0}^\infty\beta^n u(c_{t+n})\
\text{subject to:}\
c_t+k_{t+1}&=(1-\delta)k_t+f(k_t,z_t)\
c_t&=\epsilon_t k_t^\alpha+(1-\alpha)z_t\
\log z_{t+1}&=\rho \log z_t+\varepsilon_{t+1}
\end{aligned}
where:
To solve the model, we will use a combination of numerical methods. The code below defines the parameters:
main.m228 chars6 lines
main.m48 chars2 lines
The steady-state is computed analytically as follows:
main.m109 chars4 lines
The code below simulates the RBC model:
main.m557 chars16 lines
The variables y and c contain the output and consumption generated by the model.
Note: this is a basic example of an RBC model, and it can be extended to include more complex features such as multiple sectors or a government sector.
gistlibby LogSnag