%%javascript IPython.OutputArea.prototype._should_scroll = function(lines) { return false; } # KEEP GRAPHICS IN THE MAIN NOTEBOOK FLOW %matplotlib inline # GRAPHICS SETUP # # seaborn-whitegrid styles and figure size... from matplotlib import pyplot as plt plt.style.use('seaborn-whitegrid') figure_size = plt.rcParams["figure.figsize"] figure_size[0] = 10 figure_size[1] = 7 plt.rcParams["figure.figsize"] = figure_size # IMPORT LIBRARIES... import numpy as np import pandas as pd # DEFINE OUR SOLOW GROWTH MODEL SIMULATION FUNCTION... # # we are going to want to see what happens for lots of # different model parameter values and initial conditions, # so stuff everything inside a function, so we can then # invoke it with a single line... def sgm_2_200yr_run(L0, E0, n=0, g=0, s=0.15, alpha=0.5, delta=0.025, delta_n = 0, delta_g = 0, delta_s = 0, T = 200): sg_df = pd.DataFrame(index=range(T),columns=['Labor', 'Efficiency', 'Capital', 'Output', 'Output_per_Worker', 'Capital_Output_Ratio'], dtype='float') sg_df.Labor[0] = L0 sg_df.Efficiency[0] = E0 sg_df.Capital_Output_Ratio[0] = s/(n+g+delta) sg_df.Output[0] = sg_df.Capital_Output_Ratio[0]**(alpha/(1-alpha)) * sg_df.Labor[0] * sg_df.Efficiency[0] sg_df.Output_per_Worker[0] = sg_df.Output[0]/sg_df.Labor[0] sg_df.Capital = sg_df.Capital_Output_Ratio[0] * sg_df.Output[0] s = s + delta_s g = g + delta_g n = n + delta_n for i in range(T): sg_df.Labor[i+1] = sg_df.Labor[i] + sg_df.Labor[i] * n sg_df.Efficiency[i+1] = sg_df.Efficiency[i] + sg_df.Efficiency[i] * g sg_df.Capital[i+1] = sg_df.Capital[i] - sg_df.Capital[i] * delta + sg_df.Output[i] * s sg_df.Output[i+1] = (sg_df.Capital[i+1]**alpha * (sg_df.Labor[i+1] * sg_df.Efficiency[i+1])**(1-alpha)) sg_df.Output_per_Worker[i+1] = sg_df.Output[i+1]/sg_df.Labor[i+1] sg_df.Capital_Output_Ratio[i+1] = sg_df.Capital[i+1]/sg_df.Output[i+1] fig = plt.figure(figsize=(12, 12)) ax1 = plt.subplot(2,3,1) sg_df.Labor.plot(ax = ax1, title = "Labor Force") plt.ylabel("Values") ax2 = plt.subplot(2,3,2) sg_df.Efficiency.plot(ax = ax2, title = "Efficiency of Labor") ax3 = plt.subplot(2,3,3) sg_df.Capital.plot(ax = ax3, title = "Capital Stock") ax4 = plt.subplot(2,3,4) sg_df.Output.plot(ax = ax4, title = "Output") plt.ylabel("Values") plt.xlabel("Years") ax5 = plt.subplot(2,3,5) sg_df.Output_per_Worker.plot(ax = ax5, title = "Output per Worker") plt.xlabel("Years") ax6 = plt.subplot(2,3,6) sg_df.Capital_Output_Ratio.plot(ax = ax6, title = "Capital-Output Ratio") plt.xlabel("Years") plt.suptitle('Solow Growth Model: Simulation Run', size = 20) plt.show() print(alpha, "is the orientation-of-growth-toward-capital parameter: alpha") print(delta, "is the depreciation rate: delta") if (delta_n != 0): print(n, "is the alternative labor-force growth rate: n'") print(n - delta_n, "is the baseline labor-force growth rate: n") else: print(n, "is the labor force growth rate: n") if (delta_g != 0): print(g, "is the alternative efficiency-of-labor growth rate: g'") print(g - delta_g, "is the baseline efficiency-of-labor growth rate: g") else: print(g, "is the efficiency of labor growth rate: g") if (delta_s != 0): print(s, "is the alternative post-jump savings-investment share: s'") print(s - delta_s, "is the baseline pre-jump savings-investment share: s") else: print(s, "is the savings-investment share: s") print("Function creation ran without visible errors") # start with a model with no labor force or # efficiency of labor growth... sgm_2_200yr_run(L0 = 1000, E0 = 1, g = 0, n = 0, s = 0.15, delta_s = 0.03) # it works in reverse... # # start with a model with no labor force or # efficiency of labor growth... sgm_2_200yr_run(L0 = 1000, E0 = 1, g = 0, n = 0, s = 0.15, delta_s = -0.03) # Add in labor-force growth sgm_2_200yr_run(L0 = 1000, E0 = 1, g = 0, n = 0.015, s = 0.15, delta_s = 0.03, T=200) # Add in efficiency-of-labor growth sgm_2_200yr_run(L0 = 1000, E0 = 0.1, g = 0.02, n = 0.015, s = 0.15, delta_s = 0.03, T=200) sgm_2_200yr_run(L0 = 1000, E0 = 1, g = 0.015, n = 0.01, s = 0.16, delta_s = 0.04, T=100)