%Model Description++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Standard RBC model taken from Chapter 5 of Advanced Macroeconommics by David
Romer.

The model is able to replicate a key stylised fact of business cycles, namely 
the relative volatilities of consumption, output, and investment. Over the 
business cycle investment tends to be far more volatile than output, and output 
tends to be more volatile than consumption and this model is able to replicate 
this feature of the data.  However, the only reason the model is able to match 
this key feature of the data is because the exogenous productivity (and 
government spending shocks) are assumed to be highly persistent.  Such large and
persistent shocks to productivity/technology are hard to identify in the data.
 
Model suffers from other issues common to RBC models, for example the model has
no room for involuntary unemployment.  In this model, workers  choose to be 
unemployed (or under employed!): workers optimally adjust their labor supply 
across time in response to changes in the real wage (which in turn are driven by
exogenous productivity/technology shocks).      

Note that there are two sources of growth in Romer's RBC: technology growth and 
population growth. Thus we will need to detrend variables accordingly in order 
to have a stationary model.  All variables, with the exception of l(t), are 
expressed in per effective worker terms.  The labor supply, l(t), is in per 
capita terms.

%Model Information++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Name = Romer's RBC model;

%Parameters+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Definition of exogenous parameters of this RBC are as follows:

# discount rate
rho = 0.01;

# Calibrated steady state labour, in the SS solver the parameter b now gets determined
l_bar = 2.0/3.0;

# Household size (normalized to unity)
H = 1.0;

# growth rate of technology
g = 0.005;

# population growth rate 
n = 0.0025; 

# rate of capital depreciation
delta = 0.025; 

# capital's  share of output
alpha = 1.0/3.0;

# government spending per effective worker is chosen so that in SS government
# spending roughly is 20% of output (which matches U.S. data)
# g_bar now gets determined residually in the SS solver
gov_share = 0.20;

# persistence of technology shocks
rho_A = 0.95;

# pesistence of government spending shocks
rho_G = 0.95;

# standard deviation of technology shocks
sigma_A = 0.011;

# standard deviation of government spending shocks
sigma_G = 0.011;

# Various easily computed steady-state values
z_A_bar = 1.0;
z_G_bar = 1.0;

%Variable Vectors+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Only endogenous state variable is capital per effective worker, k; the
# two exogenous variables are technology, A, and government spending, G.  Both
# are driven by AR(1) processes z_A and z_G, respectively. 

[1]  y(t):output{con}[log,cf]
[2]  y2(t):output2{con}[log,cf]
[3]  k(t):physical_capital{endo}[log,cf]
[4]  k2(t):physical_capital2{endo}[log,cf]
[5]  l(t):labor{con}[log,cf]
[6]  c(t):consumption{con}[log,cf]
[7]  c2(t):consumption2{con}[log,cf]
[8]  i(t):investment{con}[log,cf]
[9]  i2(t):investment2{con}[log,cf]
[10] w(t):real_wage{con}[log]
[11] R(t):gross_interest_rate{con}
[12] g(t):gov_spending{con}[log,cf]
[13] g2(t):gov_spending2{con}[log,cf]
[14] z_A(t):eps_A(t):tech_shocks{exo}[log,cf]
[15] z_G(t):eps_G(t):gov_shocks{exo}[log,cf]

%Boundary Conditions++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
None

%Variable Substitution Non-Linear System++++++++++++++++++++++++++++++++++++++++
[10] @F(t)       = z_A(t)*k(t-1)**alpha*l(t)**(1-alpha);
[10] @F_bar      = SS{@F(t)};
[11] @Fk(t)      = DIFF{@F(t),k(t-1)};
[12] @Fl(t)      = DIFF{@F(t),l(t)};
[13] @Fk_bar     = SS{@Fk(t)};
[14] @Fl_bar     = SS{@Fl(t)};

%Non-Linear First-Order Conditions++++++++++++++++++++++++++++++++++++++++++++++
# Evolution of physical capital
[1] k(t) * EXP(n + g) - ((1 - delta) * k(t-1) + i(t)) = 0;

# Definition of capital2
[2] k2(t) - k(t)/(z_A(t)*l(t)) = 0;

# Definition of investment2
[3] i2(t) - i(t)/(z_A(t)*l(t)) = 0;
        
# Aggregate resource constraint
[4] y(t) - c(t) - i(t) - g(t) = 0;

# Definition of consumption2
[5] c2(t) - c(t)/(z_A(t)*l(t)) = 0;

# production process
[6] y(t) - @F(t) = 0;

# Definition of output2
[7] y2(t) - y(t)/(z_A(t)*l(t)) = 0;

# labor is paid its marginal product
[8] w(t) - @Fl(t) = 0;

# capital is paid its marginal product
[9] R(t) - (1 + @Fk(t) - delta) = 0;

# consumption Euler equation
[10] 1 - EXP(-(rho + g)) * (c(t) / E(t)|c(t+1)) * E(t)|R(t+1) = 0;

# intra-temporal consumption/labor supply trade-off
[11] b * c(t) - (1-l(t)) * w(t) = 0;

# evolution of government spending (per effective worker!)
[12] LOG((E(t)|g(t+1))/(g(t))) - (n+g) - (E(t)|z_G(t+1)/z_G(t)) = 0;

# Definition of government_spend2
[13] g2(t) - g(t)/(z_A(t)*l(t)) = 0;

# technology shocks
[14] LOG(E(t)|z_A(t+1)) - rho_A * LOG(z_A(t)) = 0;

# government spending shocks
[15] LOG(E(t)|z_G(t+1)) - rho_G * LOG(z_G(t)) = 0;

%Steady States [Closed form]++++++++++++++++++++++++++++++++++++++++++++++++++++
None
 
%Steady State Non-Linear System [Manual]++++++++++++++++++++++++++++++++++++++++
[1]  (EXP(n + g) - 1.0 + delta) * k_bar - i_bar = 0;
[2]  y_bar - c_bar - i_bar - g_bar = 0;
[3]  y_bar - @F_bar = 0;
[4]  w_bar - @Fl_bar = 0;
[5]  R_bar - (1 + @Fk_bar - delta) = 0;
[6]  R_bar - (1.0/EXP(-(rho + g))) = 0;
[7]  b*c_bar - (1 - l_bar)*w_bar = 0;
[8]  g_bar - y_bar*gov_share = 0;
[9]  c2_bar - (c_bar/l_bar) = 0;
[10] y2_bar - (y_bar/l_bar) = 0;
[11] i2_bar - (i_bar/l_bar) = 0;
[12] k2_bar - (k_bar/l_bar) = 0;
[13] g2_bar - (g_bar/l_bar) = 0;

# initial values for numerical steady-state computation
[1]  k_bar = 5.0;
[2]  y_bar = @F_bar;
[3]  w_bar = @Fl_bar;
[4]  R_bar = 1 + @Fk_bar - delta;
[5]  b = 2.0;
[6]  c_bar = 1.5;
[7]  g_bar = y_bar * gov_share;
[8]  i_bar = y_bar - c_bar - g_bar;
[9]  c2_bar = (c_bar/l_bar);
[10] y2_bar = (y_bar/l_bar);
[11] i2_bar = (i_bar/l_bar);
[12] k2_bar = (k_bar/l_bar);
[13] g2_bar = (g_bar/l_bar);

%Log-Linearized Model Equations+++++++++++++++++++++++++++++++++++++++++++++++++
None

%Variance-Covariance Matrix+++++++++++++++++++++++++++++++++++++++++++++++++++++
Sigma = [sigma_A**2    0;
         0    sigma_G**2]; 

%End Of Model File++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

