def test_solve_farmer_model_y_t(setup_solve_farmer_model, expected_solve_farmer_model): calc_s_t, calc_c_t, calc_k_t, calc_y_t = solve_farmer_model( **setup_solve_farmer_model) assert_almost_equal(calc_y_t, expected_solve_farmer_model["y_t"], decimal=6)
# Set parameter values. beta = 0.95 alpha = 0.3 delta = 0.1 rho = 0.9 # Set the number of time periods to simulate. T = 100 # first 10 periods given inital_productivity_state = [ 0, -0.005, -0.009, -0.013, -0.022, -0.021, -0.019, -0.011, -0.012, -0.003 ] # Get simulation result. s_t, c_t, k_t, y_t = solve_farmer_model(alpha, beta, delta, rho, T, inital_productivity_state) # plot time series. time_1 = np.array(list(range(T))) time_2 = np.array(list(range(T + 1))) sns.set_style("whitegrid") fig, ax = plt.subplots(figsize=(T / 8, T / 16)) # Productivity state, consumption, capital and output against time. ax.plot(time_1, s_t, label="productivity state", color="C7", alpha=0.7, linestyle='dashdot')