In [ ]:


In [ ]:


In [ ]:

component household production government $\Sigma$
planned government spending $+G$ $-G$ 0
transfer payments $+G_{transfers}$ $-G_{transfers}$ 0
final consumption $-C$ $+C$ 0
sales tax $-T_{sales}$ $+T_{sales}$ 0
income tax $-T_{income}$ $+T_{income}$ 0
factor income $+W$ $-W$ 0
interest $+i$ $-i$ 0
[output] $[Y]$
stock $-\Delta H$ $+\Delta M$
$\Sigma$ $0$ $0$ $0$
$$Y = C + G$$$$Y_{taxable} = W + i$$$$T_{income} = \theta Y_{taxable}$$$$Y_{disposable} = Y$$$$T_{sales} = vC_0$$$$C_0 = \frac {C}{1+v}$$

In [1]:
# import required Python libraries
import matplotlib.pyplot as plt
import numpy as np
%matplotlib inline  

# set the number of time steps
N = 300

# initialise containers for endogenous variables
C = np.zeros(N) # consumption
Y = np.zeros(N) # income
Y_t = np.zeros(N) # taxable income
Y_d = np.zeros(N) # disposable income
T_i = np.zeros(N) # tax revenue
T_s = np.zeros(N) # tax revenue
i   = np.zeros(N) # interest
H_h = np.zeros(N) # private savings
H_g = np.zeros(N) # government debt
W   = np.zeros(N)

G = 20
G_t = 5

theta = 0.25
omega = 0.1

r = 0.02

alpha_y = 0.8
alpha_h = 0.2


for t in range(1, N):
    # calculate consumer spending
    C[t] = alpha_y*Y_d[t-1] + alpha_h*H_h[t-1] 
        
    # calculate total production 
    Y[t] = G + C[t]
    
    T_s[t] = (omega*C[t])/(1+omega)
    
    W[t] = Y[t] - T_s[t] 
    
    i[t] = r*H_h[t-1]
    
    Y_t[t] = W[t] + i[t]
    
    # calculate the tax take
    T_i[t] = theta * Y_t[t]
    
    # calculate disposable income
    Y_d[t] = Y_t[t] - T_i[t] + G_t
    
    # calculate the change in private savings
    H_h[t] = H_h[t-1] + (1-alpha_y)*Y_d[t-1] - (alpha_h)*H_h[t-1]
    
    # calculate the change in government debt from rUK operations
    H_g[t] = H_g[t-1] + T_i[t] + T_s[t] - G - G_t - i[t]

In [2]:
fig = plt.figure(figsize=(14, 10))

consumption_plot = fig.add_subplot(341, xlim=(0, N), ylim=(0, np.max([np.max(Y),np.max(Y)])*1.1))
consumption_plot.plot(range(N), C, lw=3)
consumption_plot.grid()
# label axes
plt.xlabel('time')
plt.ylabel('consumption')

gov_plot = fig.add_subplot(342, xlim=(0, N), ylim=(0, np.max((Y))*1.1))
gov_plot.plot(range(N), np.repeat(G,N), lw=3)
gov_plot.grid()
# label axes
plt.xlabel('time')
plt.ylabel('government spending')

#ca_plot = fig.add_subplot(343, xlim=(0, N), ylim=(np.min([np.min(CA_UK),np.min(CA_S)])*1.1, np.max([np.max(CA_UK),np.max(CA_S)])*1.1))
#ca_plot.plot(range(N), CA_UK, lw=3)
#ca_plot.grid()
## label axes
#plt.xlabel('time')
#plt.ylabel('trade balance')

income_plot = fig.add_subplot(344, xlim=(0, N), ylim=(0, np.max(Y)*1.1))
income_plot.plot(range(N), Y, lw=3)
income_plot.grid()
# label axes
plt.xlabel('time')
plt.ylabel('income')

tax_plot = fig.add_subplot(345, xlim=(0, N), ylim=(0, np.max(T_i+T_s)*1.1))
tax_plot.plot(range(N), T_i+T_s, lw=3)
tax_plot.plot(range(N), T_i, lw=3)
tax_plot.plot(range(N), T_s, lw=3)
tax_plot.grid()
# label axes
plt.xlabel('time')
plt.ylabel('tax revenue')

tax_gdp_plot = fig.add_subplot(346, xlim=(0, N), ylim=(0, 1))
tax_gdp_plot.plot(range(N), (T_i+T_s)/Y, lw=3)
tax_gdp_plot.plot(range(N), T_i/Y, lw=3)
tax_gdp_plot.plot(range(N), T_s/Y, lw=3)
tax_gdp_plot.grid()
# label axes
plt.xlabel('time')
plt.ylabel('tax revenue (% GDP)')

deficit_plot = fig.add_subplot(347, xlim=(0, N), ylim=(-100,100))
deficit_plot.plot(range(N), T_i+T_s-np.repeat(G,N)-np.repeat(G_t,N)-i, lw=3)
deficit_plot.grid()
# label axes
plt.xlabel('time')
plt.ylabel('government budget')

debt_plot = fig.add_subplot(348, xlim=(0, N), ylim=(np.min(H_g)*1.1,0))
debt_plot.plot(range(N), H_g, lw=3)
debt_plot.grid()
# label axes
plt.xlabel('time')
plt.ylabel('government debt')

gov_balance_gdp_plot = fig.add_subplot(3,4,9, xlim=(0, N), ylim=(-1, 1))
gov_balance_gdp_plot.plot(range(N-1), (T_i[1:]+T_s[1:]-np.repeat(G,N-1)-np.repeat(G_t,N-1)-i[t])/Y[1:], lw=3)
gov_balance_gdp_plot.grid()
# label axes
plt.xlabel('time')
plt.ylabel('government balance (% GDP)')

private_balance_gdp_plot = fig.add_subplot(3,4,10, xlim=(0, N), ylim=(-1,1))
private_balance_gdp_plot.plot(range(N-1), np.diff(H_h)/Y[1:], lw=3)
private_balance_gdp_plot.grid()
# label axes
plt.xlabel('time')
plt.ylabel('private balance (% GDP)')

# space subplots neatly
plt.tight_layout()


-c:41: RuntimeWarning: invalid value encountered in divide
-c:42: RuntimeWarning: invalid value encountered in divide
-c:43: RuntimeWarning: invalid value encountered in divide

In [57]:
i


Out[57]:
array([  0.00000000e+00,   0.00000000e+00,   0.00000000e+00,
         4.20000000e-02,   1.10295652e-01,   1.95121869e-01,
         2.90406930e-01,   3.92375859e-01,   4.98681927e-01,
         6.07866570e-01,   7.19023542e-01,   8.31590059e-01,
         9.45216925e-01,   1.05968777e+00,   1.17486882e+00,
         1.29067767e+00,   1.40706387e+00,   1.52399684e+00,
         1.64145835e+00,   1.75943786e+00,   1.87792963e+00,
         1.99693088e+00,   2.11644070e+00,   2.23645932e+00,
         2.35698773e+00,   2.47802732e+00,   2.59957981e+00,
         2.72164709e+00,   2.84423114e+00,   2.96733406e+00,
         3.09095796e+00,   3.21510500e+00,   3.33977738e+00,
         3.46497730e+00,   3.59070698e+00,   3.71696865e+00,
         3.84376457e+00,   3.97109699e+00,   4.09896818e+00,
         4.22738042e+00,   4.35633600e+00,   4.48583722e+00,
         4.61588637e+00,   4.74648580e+00,   4.87763781e+00,
         5.00934475e+00,   5.14160897e+00,   5.27443282e+00,
         5.40781868e+00,   5.54176892e+00,   5.67628592e+00,
         5.81137210e+00,   5.94702984e+00,   6.08326159e+00,
         6.22006975e+00,   6.35745678e+00,   6.49542511e+00,
         6.63397722e+00,   6.77311557e+00,   6.91284264e+00,
         7.05316092e+00,   7.19407291e+00,   7.33558113e+00,
         7.47768809e+00,   7.62039634e+00,   7.76370841e+00,
         7.90762687e+00,   8.05215427e+00,   8.19729319e+00,
         8.34304622e+00,   8.48941597e+00,   8.63640503e+00,
         8.78401603e+00,   8.93225160e+00,   9.08111438e+00,
         9.23060703e+00,   9.38073221e+00,   9.53149260e+00,
         9.68289088e+00,   9.83492976e+00,   9.98761194e+00,
         1.01409402e+01,   1.02949171e+01,   1.04495456e+01,
         1.06048283e+01,   1.07607681e+01,   1.09173677e+01,
         1.10746299e+01,   1.12325575e+01,   1.13911533e+01,
         1.15504202e+01,   1.17103609e+01,   1.18709784e+01,
         1.20322755e+01,   1.21942551e+01,   1.23569200e+01,
         1.25202732e+01,   1.26843176e+01,   1.28490561e+01,
         1.30144916e+01,   1.31806271e+01,   1.33474656e+01,
         1.35150100e+01,   1.36832633e+01,   1.38522285e+01,
         1.40219086e+01,   1.41923067e+01,   1.43634258e+01,
         1.45352689e+01,   1.47078391e+01,   1.48811395e+01,
         1.50551731e+01,   1.52299432e+01,   1.54054527e+01,
         1.55817048e+01,   1.57587027e+01,   1.59364495e+01,
         1.61149483e+01,   1.62942025e+01,   1.64742151e+01,
         1.66549893e+01,   1.68365285e+01,   1.70188358e+01,
         1.72019144e+01,   1.73857677e+01,   1.75703989e+01,
         1.77558113e+01,   1.79420083e+01,   1.81289930e+01,
         1.83167690e+01,   1.85053394e+01,   1.86947078e+01,
         1.88848774e+01,   1.90758516e+01,   1.92676339e+01,
         1.94602276e+01,   1.96536363e+01,   1.98478633e+01,
         2.00429121e+01,   2.02387862e+01,   2.04354890e+01,
         2.06330242e+01,   2.08313952e+01,   2.10306055e+01,
         2.12306587e+01,   2.14315584e+01,   2.16333081e+01,
         2.18359115e+01,   2.20393721e+01,   2.22436936e+01,
         2.24488796e+01,   2.26549338e+01,   2.28618598e+01,
         2.30696614e+01,   2.32783423e+01,   2.34879061e+01,
         2.36983566e+01,   2.39096976e+01,   2.41219328e+01,
         2.43350660e+01,   2.45491010e+01,   2.47640416e+01,
         2.49798917e+01,   2.51966551e+01,   2.54143357e+01,
         2.56329373e+01,   2.58524638e+01,   2.60729192e+01,
         2.62943074e+01,   2.65166324e+01,   2.67398980e+01,
         2.69641083e+01,   2.71892673e+01,   2.74153790e+01,
         2.76424474e+01,   2.78704766e+01,   2.80994706e+01,
         2.83294335e+01,   2.85603694e+01,   2.87922825e+01,
         2.90251768e+01,   2.92590566e+01,   2.94939260e+01,
         2.97297891e+01,   2.99666502e+01,   3.02045135e+01,
         3.04433833e+01,   3.06832637e+01,   3.09241592e+01,
         3.11660739e+01,   3.14090122e+01,   3.16529784e+01,
         3.18979769e+01,   3.21440120e+01,   3.23910882e+01,
         3.26392097e+01,   3.28883812e+01,   3.31386069e+01,
         3.33898913e+01,   3.36422390e+01,   3.38956545e+01,
         3.41501421e+01,   3.44057066e+01,   3.46623524e+01,
         3.49200841e+01,   3.51789064e+01,   3.54388237e+01,
         3.56998408e+01,   3.59619624e+01,   3.62251930e+01,
         3.64895374e+01,   3.67550003e+01,   3.70215864e+01,
         3.72893005e+01,   3.75581473e+01,   3.78281317e+01,
         3.80992584e+01,   3.83715323e+01,   3.86449583e+01,
         3.89195412e+01,   3.91952859e+01,   3.94721973e+01,
         3.97502804e+01,   4.00295401e+01,   4.03099814e+01,
         4.05916093e+01,   4.08744288e+01,   4.11584450e+01,
         4.14436630e+01,   4.17300877e+01,   4.20177243e+01,
         4.23065780e+01,   4.25966539e+01,   4.28879572e+01,
         4.31804930e+01,   4.34742666e+01,   4.37692832e+01,
         4.40655481e+01,   4.43630665e+01,   4.46618438e+01,
         4.49618852e+01,   4.52631962e+01,   4.55657821e+01,
         4.58696483e+01,   4.61748002e+01,   4.64812433e+01,
         4.67889830e+01,   4.70980248e+01,   4.74083742e+01,
         4.77200368e+01,   4.80330180e+01,   4.83473236e+01,
         4.86629590e+01,   4.89799299e+01,   4.92982421e+01,
         4.96179010e+01,   4.99389125e+01,   5.02612822e+01,
         5.05850160e+01,   5.09101195e+01,   5.12365986e+01,
         5.15644591e+01,   5.18937069e+01,   5.22243477e+01,
         5.25563876e+01,   5.28898323e+01,   5.32246880e+01,
         5.35609605e+01,   5.38986558e+01,   5.42377800e+01,
         5.45783390e+01,   5.49203391e+01,   5.52637862e+01,
         5.56086865e+01,   5.59550461e+01,   5.63028713e+01,
         5.66521681e+01,   5.70029429e+01,   5.73552019e+01,
         5.77089514e+01,   5.80641976e+01,   5.84209470e+01,
         5.87792059e+01,   5.91389806e+01,   5.95002775e+01,
         5.98631032e+01,   6.02274641e+01,   6.05933667e+01,
         6.09608174e+01,   6.13298229e+01,   6.17003898e+01,
         6.20725246e+01,   6.24462339e+01,   6.28215245e+01,
         6.31984031e+01,   6.35768762e+01,   6.39569508e+01,
         6.43386335e+01,   6.47219312e+01,   6.51068507e+01])

In [ ]: