-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPython code for the example model
More file actions
54 lines (40 loc) · 1.26 KB
/
Python code for the example model
File metadata and controls
54 lines (40 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import numpy as np
from scipy.integrate import odeint
from scipy.interpolate import interp1d
import matplotlib.pyplot as plt
import pandas as pd
data = pd.read_excel('/Models/Data.xls')
time_points = data['Time'].values
I_Data = interp1d(time_points, data['Investment Data'].values, fill_value="extrapolate")
G_Data = interp1d(time_points, data['Government Expenditure Data'].values, fill_value="extrapolate")
NX_Data = interp1d(time_points, data['Net Exports Data'].values, fill_value="extrapolate")
GDP_Data = interp1d(time_points, data['GDP Data'].values, fill_value="extrapolate")
Reference_MPC = 0.8
alpha = 0.4
def model(y, t, MPC, EFT, PAT, I, G, NX):
EI, GDP = y
I = I_Data(t)
G = G_Data(t)
NX = NX_Data(t)
def calculate_mpc(t):
if 2020 <= t <= 2020.25:
return Reference_MPC * (1 - alpha)
else:
return Reference_MPC
MPC = calculate_mpc(t)
C = MPC * EI
delta_EI = (GDP - EI) / EFT
delta_GDP = (C + I + G + NX - GDP) / PAT
return [delta_EI, delta_GDP]
MPC = 0.8
EFT = 2
PAT = 1
I = 10
G = 80
NX = 10
EI0 = 250
GDP0 = 250
y0 = [EI0, GDP0]
t = np.arange(2013, 2023, 0.25)
results = odeint(model, y0, t, args=(MPC, EFT, PAT, I, G, NX))
EI_results, GDP_results = results.T