This document provides guidelines on how to use the godley package to create the SIMEX model — a model with government money and expectations, as described by Wynne Godley and Marc Lavoie in Chapter 3 of Monetary Economics: An Integrated Approach to Credit, Money, Income, Production, and Wealth.
Base scenario
Start by initializing an empty SFC (Stock-Flow Consistent) model:
# Create empty model
model_simex <- create_model(name = "SFC SIMEX")
#> Empty model created
Define the variables for the model:
# Add variables
model_simex <- model_simex |>
add_variable("C_d", desc = "Consumption demand by households") |>
add_variable("C_s", desc = "Consumption supply") |>
add_variable("G_s", desc = "Government supply") |>
add_variable("T_d", desc = "Taxes, demand") |>
add_variable("T_s", desc = "Taxes, supply") |>
add_variable("N_d", desc = "Demand for labor") |>
add_variable("N_s", desc = "Supply of labor") |>
add_variable("H_h", desc = "Cash money held by households") |>
add_variable("H_s", desc = "Cash money supplied by the government") |>
add_variable("H_d", desc = "Cash money demanded by the government") |>
add_variable("Y", desc = "Income = GDP") |>
add_variable("Yd", desc = "Disposable income of households") |>
add_variable("Yd_e", desc = "Expected disposable income of households") |>
add_variable("alpha1", init = 0.6, desc = "Propensity to consume out of income") |>
add_variable("alpha2", init = 0.4, desc = "Propensity to consume out of wealth") |>
add_variable("theta", init = 0.2, desc = "Tax rate") |>
add_variable("G_d", init = 20, desc = "Government demand") |>
add_variable("W", init = 1, desc = "Wage rate")
Establish the relationships between variables by adding equations:
# Add equations
model_simex <- model_simex |>
add_equation("C_s = C_d", desc = "Consumption") |>
add_equation("G_s = G_d") |>
add_equation("T_s = T_d") |>
add_equation("N_s = N_d") |>
add_equation("Yd = W * N_s - T_s") |>
add_equation("T_d = theta * W * N_s") |>
add_equation("C_d = alpha1 * Yd_e + alpha2 * H_h[-1]") |>
add_equation("H_s = G_d - T_d + H_s[-1]") |>
add_equation("H_h = Yd - C_d + H_h[-1]") |>
add_equation("Y = C_s + G_s") |>
add_equation("N_d = Y/W") |>
add_equation("H_d = Yd_e - C_d + H_h[-1]") |>
add_equation("Yd_e = Yd[-1]") |>
add_equation("H_s = H_h", desc = "Money equilibrium", hidden = TRUE)
Now, you can simulate the model (in this example, we calculate the baseline scenario over 100 periods using the Newton method)
# Simulate model
model_simex <- simulate_scenario(model_simex,
scenario = "baseline", max_iter = 350, periods = 100,
hidden_tol = 0.1, tol = 1e-05, method = "Newton"
)
#> Model prepared successfully
#> Simulating scenario baseline (1 of 1)
#> Scenario(s) successfully simulated
With the simulation estimated, visualize the results for the variables of interest:
# Plot results
plot_simulation(
model = model_simex, scenario = c("baseline"), from = 1, to = 50,
expressions = c("Y", "C_d", "C_s / alpha1")
)
Note: The above example uses the new pipe operator
(|>
), which requires R 4.1 or later.
Shock scenario
With godley
package you can simulate how shocks affect
the economy (specifically, how they impact the base scenario).
In this example, we introduce an increase in government expenditures.
First, initialize an empty shock object:
# Create empty shock
shock_simex <- create_shock()
#> Shock object created
Define the shock by adding an appropriate equation:
# Add shock equation with increased government expenditures
shock_simex <- add_shock(shock_simex,
variable = "G_d", value = 25,
desc = "Increase in government expenditures", start = 5, end = 50
)
Integrate the shock into the model by creating a new scenario:
# Create new scenario with this shock
model_simex <- add_scenario(model_simex,
name = "expansion", origin = "baseline", shock = shock_simex
)
Simulate the scenario with the shock applied:
# Simulate shock
model_simex <- simulate_scenario(model_simex,
scenario = "expansion", max_iter = 350, periods = 100,
hidden_tol = 0.1, tol = 1e-08, method = "Newton"
)
#> Simulating scenario expansion (1 of 1)
#> Scenario(s) successfully simulated
Finally, plot the simulation outcomes:
# Plot results
plot_simulation(
model = model_simex, scenario = c("expansion"), from = 1, to = 50,
expressions = c("Y", "C_d", "C_s / alpha1")
)