Time Series Forecasting - Box-Jekins Methon (ARIMA) in Python and

Time Series Forecasting - FBProphet in Python

China Inflation - Consumer Price Annual Percentage Forecasting

In [4]:
# ignore warnings
import pandas as pd
import warnings
warnings.filterwarnings("ignore")

Load dataset

In [5]:
# load dataset
from pandas import read_csv
from pandas import datetime
from matplotlib import pyplot
from pandas.plotting import autocorrelation_plot

filename = 'China_Inflation_ConsumerPriceData_Annual_percentages.csv'

df = read_csv(filename)
df = df.set_index('Year')

df.plot(figsize = (8,6))

fig = pyplot.figure(figsize = (8,6))
autocorrelation_plot(df)
pyplot.show()

print(df.head(5))
      Inflation_ConsumerPrice_Annual_Percentage
Year                                           
1987                                   7.233836
1988                                  18.811818
1989                                  18.245638
1990                                   3.052290
1991                                   3.556686

Autocorrelation and Partial Autocorrelation in Python

In [6]:
from statsmodels.graphics.tsaplots import plot_acf
import matplotlib.pyplot as plt

plt.rcParams.update({'figure.figsize':(6,4), 'figure.dpi':120})

plot_acf(df)
pyplot.show()
In [7]:
from statsmodels.graphics.tsaplots import plot_pacf

plot_pacf(df)
pyplot.show()

ADF test

In [8]:
from statsmodels.tsa.stattools import adfuller

# ADF Test
def adf_test(series):
    result = adfuller(series, autolag='AIC')
    print(); print(f'ADF Statistic: {result[0]}')
    print();  print(f'n_lags: {result[1]}')
    print();  print(f'p-value: {result[1]}')

    print(); print('Critial Values:')
    for key, value in result[4].items():
        print(f'   {key}, {value}')   

adf_test(df["Inflation_ConsumerPrice_Annual_Percentage"])
ADF Statistic: -6.218024354742872

n_lags: 5.306842159262952e-08

p-value: 5.306842159262952e-08

Critial Values:
   1%, -3.7112123008648155
   5%, -2.981246804733728
   10%, -2.6300945562130176

KPSS Test

In [9]:
from statsmodels.tsa.stattools import kpss

def kpss_test(series, **kw):    
    
    statistic, p_value, n_lags, critical_values = kpss(series, **kw)
    
    # Format Output
    print(); print(f'KPSS Statistic: {statistic}')
    print(); print(f'p-value: {p_value}')
    print(); print(f'num lags: {n_lags}')
    print(); print('Critial Values:')
    for key, value in critical_values.items():
        print(f'   {key} : {value}')
    
kpss_test(df["Inflation_ConsumerPrice_Annual_Percentage"])
KPSS Statistic: 0.33434668277342716

p-value: 0.1

num lags: 10

Critial Values:
   10% : 0.347
   5% : 0.463
   2.5% : 0.574
   1% : 0.739
/home/crown/miniconda/envs/nilimeshdss/lib/python3.6/site-packages/statsmodels/tsa/stattools.py:1278: InterpolationWarning: p-value is greater than the indicated p-value
  warn("p-value is greater than the indicated p-value", InterpolationWarning)

How to find the order of differencing (d) in ARIMA model

In [10]:
import numpy as np, pandas as pd
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
import matplotlib.pyplot as plt
plt.rcParams.update({'figure.figsize':(12,14), 'figure.dpi':120})

# Import data
#df = pd.read_csv('shampoo.csv', header=0, names = ['Sales'])
df.reset_index(drop=True, inplace=True)

# Original Series
fig, axes = plt.subplots(5, 2, sharex=True)
axes[0, 0].plot(df.values); axes[0, 0].set_title('Original Series')
plot_acf(df.values, ax=axes[0, 1])

# 1st Differencing
df1 = df["Inflation_ConsumerPrice_Annual_Percentage"].diff()
axes[1, 0].plot(df1); axes[1, 0].set_title('1st Order Differencing')
plot_acf(df1.dropna(), ax=axes[1, 1])

# 2nd Differencing
df2 = df["Inflation_ConsumerPrice_Annual_Percentage"].diff().diff()
axes[2, 0].plot(df2); axes[2, 0].set_title('2nd Order Differencing')
plot_acf(df2.dropna(), ax=axes[2, 1])

# 3rd Differencing
df3 = df["Inflation_ConsumerPrice_Annual_Percentage"].diff().diff().diff()
axes[3, 0].plot(df3); axes[3, 0].set_title('3rd Order Differencing')
plot_acf(df3.dropna(), ax=axes[3, 1])

# 3rd Differencing
df4 = df["Inflation_ConsumerPrice_Annual_Percentage"].diff().diff().diff().diff()
axes[4, 0].plot(df4); axes[4, 0].set_title('4th Order Differencing')
plot_acf(df4.dropna(), ax=axes[4, 1])

plt.show()

ADF and KPSS statistics

In [11]:
warnings.filterwarnings("ignore")

print("---------------------------------------------")
print("First Diffencing: ")
print("---------------------------------------------")
df1 = df["Inflation_ConsumerPrice_Annual_Percentage"].diff()
print(); print("---------------------------------------------")
adf_test(df1.dropna())
print(); print("---------------------------------------------")
kpss_test(df1.dropna())
print(); print("---------------------------------------------")


print(); print("---------------------------------------------")
print("2nd Diffencing: ")
print("---------------------------------------------")
df2 = df["Inflation_ConsumerPrice_Annual_Percentage"].diff().diff()
print(); print("---------------------------------------------")
adf_test(df2.dropna())
print(); print("---------------------------------------------")
kpss_test(df2.dropna())
print(); print("---------------------------------------------")

print(); print("---------------------------------------------")
print("3rd Diffencing: ")
print("---------------------------------------------")
df3 = df["Inflation_ConsumerPrice_Annual_Percentage"].diff().diff().diff()
print(); print("---------------------------------------------")
adf_test(df3.dropna())
print(); print("---------------------------------------------")
kpss_test(df3.dropna())
print(); print("---------------------------------------------")

print(); print("---------------------------------------------")
print("4th Diffencing: ")
print("---------------------------------------------")
df4 = df["Inflation_ConsumerPrice_Annual_Percentage"].diff().diff().diff().diff()
print(); print("---------------------------------------------")
adf_test(df4.dropna())
print(); print("---------------------------------------------")
kpss_test(df4.dropna())
print(); print("---------------------------------------------")
---------------------------------------------
First Diffencing: 
---------------------------------------------

---------------------------------------------

ADF Statistic: -4.440298727469107

n_lags: 0.00025170322606215525

p-value: 0.00025170322606215525

Critial Values:
   1%, -3.6699197407407405
   5%, -2.9640707407407407
   10%, -2.621171111111111

---------------------------------------------

KPSS Statistic: 0.1462787732127463

p-value: 0.1

num lags: 10

Critial Values:
   10% : 0.347
   5% : 0.463
   2.5% : 0.574
   1% : 0.739

---------------------------------------------

---------------------------------------------
2nd Diffencing: 
---------------------------------------------

---------------------------------------------

ADF Statistic: -7.674346310092879

n_lags: 1.5631835159544724e-11

p-value: 1.5631835159544724e-11

Critial Values:
   1%, -3.6699197407407405
   5%, -2.9640707407407407
   10%, -2.621171111111111

---------------------------------------------

KPSS Statistic: 0.24156445343961164

p-value: 0.1

num lags: 10

Critial Values:
   10% : 0.347
   5% : 0.463
   2.5% : 0.574
   1% : 0.739

---------------------------------------------

---------------------------------------------
3rd Diffencing: 
---------------------------------------------

---------------------------------------------

ADF Statistic: -4.455659590423115

n_lags: 0.00023628077940209617

p-value: 0.00023628077940209617

Critial Values:
   1%, -3.6889256286443146
   5%, -2.9719894897959187
   10%, -2.6252957653061224

---------------------------------------------

KPSS Statistic: 0.252784409516044

p-value: 0.1

num lags: 9

Critial Values:
   10% : 0.347
   5% : 0.463
   2.5% : 0.574
   1% : 0.739

---------------------------------------------

---------------------------------------------
4th Diffencing: 
---------------------------------------------

---------------------------------------------

ADF Statistic: -4.217185284614466

n_lags: 0.000616128424403896

p-value: 0.000616128424403896

Critial Values:
   1%, -3.7883858816542486
   5%, -3.013097747543462
   10%, -2.6463967573696143

---------------------------------------------

KPSS Statistic: 0.18801922891453537

p-value: 0.1

num lags: 9

Critial Values:
   10% : 0.347
   5% : 0.463
   2.5% : 0.574
   1% : 0.739

---------------------------------------------
In [ ]:
 

How to find the order of the AR term (p)

In [12]:
from statsmodels.graphics.tsaplots import plot_pacf

# PACF plot 
plt.rcParams.update({'figure.figsize':(9,3), 'figure.dpi':120})
fig, axes = plt.subplots(1, 2, sharex=True)

df2 = df["Inflation_ConsumerPrice_Annual_Percentage"].diff().diff() #.diff() #.diff()

axes[0].plot(df2); axes[0].set_title('2nd Differencing')
axes[1].set(ylim=(-3,3))
plot_pacf(df2.dropna(), ax=axes[1]) #PACF

plt.show()

How to find the order of the MA term (q)

In [13]:
from statsmodels.graphics.tsaplots import plot_acf
import matplotlib.pyplot as plt

plt.rcParams.update({'figure.figsize':(9,3), 'figure.dpi':120})
fig, axes = plt.subplots(1, 2, sharex=True)

df2 = df["Inflation_ConsumerPrice_Annual_Percentage"].diff().diff() #.diff() #.diff()
axes[0].plot(df2); axes[0].set_title('2nd Differencing')
#axes[1].set(ylim=(0,1.2))
plot_acf(df2.dropna(), ax=axes[1]) # ACF

plt.show()
In [14]:
## ADF test
adf_test(df2.dropna())
ADF Statistic: -7.674346310092879

n_lags: 1.5631835159544724e-11

p-value: 1.5631835159544724e-11

Critial Values:
   1%, -3.6699197407407405
   5%, -2.9640707407407407
   10%, -2.621171111111111

Build the ARIMA(p,d,q) Model

In [15]:
from statsmodels.tsa.arima_model import ARIMA

plt.rcParams.update({'figure.figsize':(16,6), 'figure.dpi':220})

df = read_csv(filename)
df = df.set_index('Year')

# ARIMA Model
model = ARIMA(df["Inflation_ConsumerPrice_Annual_Percentage"], order=(2,2,0))
model_fit = model.fit(disp=0)
print(model_fit.summary())

# Plot residual errors
residuals = pd.DataFrame(model_fit.resid)
fig, ax = plt.subplots(1,2)
residuals.plot(title="Residuals", ax=ax[0])
residuals.plot(kind='kde', title='Density', ax=ax[1])
plt.show()

# Actual vs Fitted
model_fit.plot_predict(dynamic=False)
plt.show()
                                          ARIMA Model Results                                           
========================================================================================================
Dep. Variable:     D2.Inflation_ConsumerPrice_Annual_Percentage   No. Observations:                   32
Model:                                           ARIMA(2, 2, 0)   Log Likelihood                -100.725
Method:                                                 css-mle   S.D. of innovations              5.584
Date:                                          Fri, 30 Jul 2021   AIC                            209.449
Time:                                                  16:49:42   BIC                            215.312
Sample:                                                       2   HQIC                           211.393
                                                                                                        
======================================================================================================================
                                                         coef    std err          z      P>|z|      [0.025      0.975]
----------------------------------------------------------------------------------------------------------------------
const                                                 -0.0796      0.599     -0.133      0.895      -1.253       1.094
ar.L1.D2.Inflation_ConsumerPrice_Annual_Percentage    -0.2097      0.174     -1.203      0.239      -0.551       0.132
ar.L2.D2.Inflation_ConsumerPrice_Annual_Percentage    -0.4870      0.183     -2.657      0.013      -0.846      -0.128
                                    Roots                                    
=============================================================================
                  Real          Imaginary           Modulus         Frequency
-----------------------------------------------------------------------------
AR.1           -0.2153           -1.4168j            1.4330           -0.2740
AR.2           -0.2153           +1.4168j            1.4330            0.2740
-----------------------------------------------------------------------------
In [ ]:
 

using Auto ARIMA

In [16]:
import pmdarima as pm

model_with_auto_d = pm.auto_arima(df, start_p=1, start_q=1,
                      test='adf',       # use adftest to find optimal 'd'
                      max_p=4, max_q=4, # maximum p, q
                      m=1,              # frequency of series
                      
                      d=None,           # let model determine 'd'
                      
                      seasonal=False,   # No Seasonality
                      start_P=0, 
                      D=0, 
                      trace=True,
                      error_action='ignore',  
                      suppress_warnings=True, 
                      stepwise=True)

print(model_with_auto_d.summary())
Fit ARIMA: order=(1, 1, 1); AIC=nan, BIC=nan, Fit time=nan seconds
Fit ARIMA: order=(0, 1, 0); AIC=203.376, BIC=206.369, Fit time=0.003 seconds
Fit ARIMA: order=(1, 1, 0); AIC=204.466, BIC=208.955, Fit time=0.015 seconds
Fit ARIMA: order=(0, 1, 1); AIC=200.578, BIC=205.067, Fit time=0.015 seconds
Fit ARIMA: order=(0, 1, 2); AIC=191.891, BIC=197.877, Fit time=0.040 seconds
Fit ARIMA: order=(1, 1, 3); AIC=nan, BIC=nan, Fit time=nan seconds
Fit ARIMA: order=(1, 1, 2); AIC=nan, BIC=nan, Fit time=nan seconds
Fit ARIMA: order=(0, 1, 3); AIC=192.131, BIC=199.614, Fit time=0.055 seconds
Total fit time: 0.159 seconds
                             ARIMA Model Results                              
==============================================================================
Dep. Variable:                    D.y   No. Observations:                   33
Model:                 ARIMA(0, 1, 2)   Log Likelihood                 -91.945
Method:                       css-mle   S.D. of innovations              3.709
Date:                Fri, 30 Jul 2021   AIC                            191.891
Time:                        16:49:44   BIC                            197.877
Sample:                             1   HQIC                           193.905
                                                                              
==============================================================================
                 coef    std err          z      P>|z|      [0.025      0.975]
------------------------------------------------------------------------------
const         -0.3071      0.117     -2.634      0.013      -0.536      -0.079
ma.L1.D.y     -0.1289      0.145     -0.887      0.382      -0.414       0.156
ma.L2.D.y     -0.8711      0.132     -6.583      0.000      -1.130      -0.612
                                    Roots                                    
=============================================================================
                  Real          Imaginary           Modulus         Frequency
-----------------------------------------------------------------------------
MA.1            1.0000           +0.0000j            1.0000            0.0000
MA.2           -1.1480           +0.0000j            1.1480            0.5000
-----------------------------------------------------------------------------
In [17]:
model_with_d_equals_1 = pm.auto_arima(df, start_p=1, start_q=1,
                      test='adf',       # use adftest to find optimal 'd'
                      max_p=4, max_q=4, max_d=4, # maximum p, q and d
                      m=1,              # frequency of series
                      
                      d=1,              # let model determine 'd'
                      
                      seasonal=False,   # No Seasonality
                      start_P=0, 
                      D=0, 
                      trace=True,
                      error_action='ignore',  
                      suppress_warnings=True, 
                      stepwise=True)

print(model_with_d_equals_1.summary())
Fit ARIMA: order=(1, 1, 1); AIC=nan, BIC=nan, Fit time=nan seconds
Fit ARIMA: order=(0, 1, 0); AIC=203.376, BIC=206.369, Fit time=0.002 seconds
Fit ARIMA: order=(1, 1, 0); AIC=204.466, BIC=208.955, Fit time=0.015 seconds
Fit ARIMA: order=(0, 1, 1); AIC=200.578, BIC=205.067, Fit time=0.014 seconds
Fit ARIMA: order=(0, 1, 2); AIC=191.891, BIC=197.877, Fit time=0.038 seconds
Fit ARIMA: order=(1, 1, 3); AIC=nan, BIC=nan, Fit time=nan seconds
Fit ARIMA: order=(1, 1, 2); AIC=nan, BIC=nan, Fit time=nan seconds
Fit ARIMA: order=(0, 1, 3); AIC=192.131, BIC=199.614, Fit time=0.055 seconds
Total fit time: 0.152 seconds
                             ARIMA Model Results                              
==============================================================================
Dep. Variable:                    D.y   No. Observations:                   33
Model:                 ARIMA(0, 1, 2)   Log Likelihood                 -91.945
Method:                       css-mle   S.D. of innovations              3.709
Date:                Fri, 30 Jul 2021   AIC                            191.891
Time:                        16:49:44   BIC                            197.877
Sample:                             1   HQIC                           193.905
                                                                              
==============================================================================
                 coef    std err          z      P>|z|      [0.025      0.975]
------------------------------------------------------------------------------
const         -0.3071      0.117     -2.634      0.013      -0.536      -0.079
ma.L1.D.y     -0.1289      0.145     -0.887      0.382      -0.414       0.156
ma.L2.D.y     -0.8711      0.132     -6.583      0.000      -1.130      -0.612
                                    Roots                                    
=============================================================================
                  Real          Imaginary           Modulus         Frequency
-----------------------------------------------------------------------------
MA.1            1.0000           +0.0000j            1.0000            0.0000
MA.2           -1.1480           +0.0000j            1.1480            0.5000
-----------------------------------------------------------------------------
In [18]:
model_with_d_equals_2 = pm.auto_arima(df, start_p=1, start_q=1,
                      test='adf',       # use adftest to find optimal 'd'
                      max_p=4, max_q=4, # maximum p, q
                      m=1,              # frequency of series
                      
                      d=2,              # let model determine 'd'
                      
                      seasonal=False,   # No Seasonality
                      start_P=0, 
                      D=0, 
                      trace=True,
                      error_action='ignore',  
                      suppress_warnings=True, 
                      stepwise=True)

print(model_with_d_equals_2.summary())
Fit ARIMA: order=(1, 2, 1); AIC=204.471, BIC=210.334, Fit time=0.045 seconds
Fit ARIMA: order=(0, 2, 0); AIC=211.717, BIC=214.648, Fit time=0.002 seconds
Fit ARIMA: order=(1, 2, 0); AIC=213.498, BIC=217.895, Fit time=0.012 seconds
Fit ARIMA: order=(0, 2, 1); AIC=203.815, BIC=208.212, Fit time=0.029 seconds
Fit ARIMA: order=(0, 2, 2); AIC=200.133, BIC=205.996, Fit time=0.081 seconds
Fit ARIMA: order=(1, 2, 3); AIC=nan, BIC=nan, Fit time=nan seconds
Fit ARIMA: order=(1, 2, 2); AIC=199.747, BIC=207.076, Fit time=0.090 seconds
Fit ARIMA: order=(2, 2, 3); AIC=nan, BIC=nan, Fit time=nan seconds
Fit ARIMA: order=(2, 2, 2); AIC=nan, BIC=nan, Fit time=nan seconds
Total fit time: 0.288 seconds
                             ARIMA Model Results                              
==============================================================================
Dep. Variable:                   D2.y   No. Observations:                   32
Model:                 ARIMA(1, 2, 2)   Log Likelihood                 -94.874
Method:                       css-mle   S.D. of innovations              4.436
Date:                Fri, 30 Jul 2021   AIC                            199.747
Time:                        16:49:45   BIC                            207.076
Sample:                             2   HQIC                           202.177
                                                                              
==============================================================================
                 coef    std err          z      P>|z|      [0.025      0.975]
------------------------------------------------------------------------------
const         -0.0079      0.110     -0.072      0.944      -0.223       0.208
ar.L1.D2.y    -0.3412      0.212     -1.611      0.118      -0.756       0.074
ma.L1.D2.y    -0.1494      0.137     -1.087      0.286      -0.419       0.120
ma.L2.D2.y    -0.8506      0.131     -6.514      0.000      -1.107      -0.595
                                    Roots                                    
=============================================================================
                  Real          Imaginary           Modulus         Frequency
-----------------------------------------------------------------------------
AR.1           -2.9311           +0.0000j            2.9311            0.5000
MA.1            1.0000           +0.0000j            1.0000            0.0000
MA.2           -1.1757           +0.0000j            1.1757            0.5000
-----------------------------------------------------------------------------

How to interpret the residual plots in ARIMA model

In [19]:
model_with_auto_d.plot_diagnostics(figsize=(12,10))
plt.show()
In [20]:
model_with_d_equals_1.plot_diagnostics(figsize=(12,10))
plt.show()
In [21]:
model_with_d_equals_2.plot_diagnostics(figsize=(12,10))
plt.show()

Forecast

In [22]:
model = model_with_auto_d
In [23]:
# Forecast
n_periods = 10
fc, confint = model.predict(n_periods=n_periods, return_conf_int=True)
#index_of_fc = np.arange(len(df), len(df)+n_periods)
index_of_fc = np.arange(2020, 2020+n_periods)

# make series for plotting purpose
fc_series = pd.Series(fc, index=index_of_fc)
lower_series = pd.Series(confint[:, 0], index=index_of_fc)
upper_series = pd.Series(confint[:, 1], index=index_of_fc)

# Plot
plt.plot(df)
plt.plot(fc_series, color='darkgreen')
plt.fill_between(lower_series.index, 
                 lower_series, 
                 upper_series, 
                 color='k', alpha=.15)

plt.title("Final Forecast")
plt.show()

print(); print(fc_series)
print(); print(lower_series)
print(); print(upper_series)
2020    0.942078
2021   -0.870237
2022   -1.177323
2023   -1.484410
2024   -1.791496
2025   -2.098582
2026   -2.405669
2027   -2.712755
2028   -3.019841
2029   -3.326928
dtype: float64

2020    -6.328320
2021   -10.512307
2022   -10.819394
2023   -11.126480
2024   -11.433566
2025   -11.740653
2026   -12.047739
2027   -12.354825
2028   -12.661912
2029   -12.968998
dtype: float64

2020    8.212476
2021    8.771833
2022    8.464747
2023    8.157661
2024    7.850574
2025    7.543488
2026    7.236402
2027    6.929315
2028    6.622229
2029    6.315143
dtype: float64

Using FB Prophet

In [24]:
from fbprophet import Prophet
import pandas as pd

df = read_csv(filename)
#df = df.set_index('Year')

print(df.head())
#print(); print(df[['Year', 'Population']])

df["End_Year"] = 0
for i in range(0, len(df)):
    df.iloc[i, 2] = str(df.iloc[i, 0]) + '-12-' + '31'

print(); print(df.head())
   Year  Inflation_ConsumerPrice_Annual_Percentage
0  1987                                   7.233836
1  1988                                  18.811818
2  1989                                  18.245638
3  1990                                   3.052290
4  1991                                   3.556686

   Year  Inflation_ConsumerPrice_Annual_Percentage    End_Year
0  1987                                   7.233836  1987-12-31
1  1988                                  18.811818  1988-12-31
2  1989                                  18.245638  1989-12-31
3  1990                                   3.052290  1990-12-31
4  1991                                   3.556686  1991-12-31
In [25]:
# Create a new Data Frame
df_pop = pd.DataFrame()

df_pop[['ds','y']] = df[['End_Year', 'Inflation_ConsumerPrice_Annual_Percentage']]

# Convert Data Frame to FBProphet Timeseries ds and y
df_pop['ds'] = pd.to_datetime(df_pop['ds'])
df_pop['y']  = pd.to_numeric(df_pop['y'])

print(df_pop.tail())

# Create FBProphet Model with Dataset
m = Prophet(daily_seasonality=False, weekly_seasonality=True, yearly_seasonality=True)
m.fit(df_pop)

future = m.make_future_dataframe(periods=10, freq = 'Y')

print()
print(future.tail(26))

forecast = m.predict(future)
print(forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail(25))

fig = m.plot(forecast)
plt.show()


# Save Data in a CSV file
df_final = pd.DataFrame()
df_final[['Year', 'yhat', 'yhat_lower', 'yhat_upper']] = forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']]

df_final['Inflation_ConsumerPrice_Annual_Percentage'] = df_pop['y']

print(df_final.head(len(df_final)))

#df_final.to_csv('Forecast_final.csv',index = False)
           ds         y
29 2016-12-31  2.000002
30 2017-12-31  1.593136
31 2018-12-31  2.074790
32 2019-12-31  2.899234
33 2020-12-31  2.419422

           ds
18 2005-12-31
19 2006-12-31
20 2007-12-31
21 2008-12-31
22 2009-12-31
23 2010-12-31
24 2011-12-31
25 2012-12-31
26 2013-12-31
27 2014-12-31
28 2015-12-31
29 2016-12-31
30 2017-12-31
31 2018-12-31
32 2019-12-31
33 2020-12-31
34 2021-12-31
35 2022-12-31
36 2023-12-31
37 2024-12-31
38 2025-12-31
39 2026-12-31
40 2027-12-31
41 2028-12-31
42 2029-12-31
43 2030-12-31
           ds      yhat  yhat_lower  yhat_upper
19 2006-12-31  6.193986   -0.221959   11.829260
20 2007-12-31  2.002930   -3.631510    7.798222
21 2008-12-31  2.435867   -3.400488    8.030518
22 2009-12-31  1.020603   -4.851891    6.744770
23 2010-12-31  2.328589   -3.114842    7.967965
24 2011-12-31  7.660686    1.678133   13.342065
25 2012-12-31  0.967389   -4.890986    6.717942
26 2013-12-31  0.730118   -5.446970    6.241815
27 2014-12-31  0.214413   -6.012026    5.784815
28 2015-12-31 -1.139751   -7.214567    4.791593
29 2016-12-31  6.625146    0.717754   12.638405
30 2017-12-31  2.967645   -2.625725    8.929036
31 2018-12-31 -1.254065   -7.419657    4.778922
32 2019-12-31 -1.430236   -7.022282    4.188645
33 2020-12-31 -2.175291   -8.133314    3.340915
34 2021-12-31 -0.897752   -6.785047    5.006974
35 2022-12-31  4.403692   -1.544194   10.595158
36 2023-12-31  0.807291   -5.035938    6.779672
37 2024-12-31 -2.465777   -8.181385    3.505412
38 2025-12-31 -3.011928   -9.402865    2.812249
39 2026-12-31 -4.396745  -10.559514    1.042678
40 2027-12-31 -3.058105   -9.345763    2.516792
41 2028-12-31 -0.228249   -6.062967    5.595024
42 2029-12-31 -4.480406  -10.497465    0.771690
43 2030-12-31 -4.687231  -10.551563    1.018345
         Year       yhat  yhat_lower  yhat_upper  \
0  1987-12-31   7.503939    1.933629   13.034622   
1  1988-12-31  15.268835    9.609630   21.332621   
2  1989-12-31  11.611334    5.742877   17.289410   
3  1990-12-31   7.389625    1.691939   13.271426   
4  1991-12-31   7.213454    1.204935   12.927144   
5  1992-12-31   6.468398    0.246673   12.224215   
6  1993-12-31   7.745937    1.920965   13.753098   
7  1994-12-31  13.047381    7.375697   18.628802   
8  1995-12-31   9.450981    3.548152   15.461609   
9  1996-12-31   6.177913    0.280628   12.032016   
10 1997-12-31   5.631761   -0.541456   11.110879   
11 1998-12-31   4.246944   -1.706499   10.418880   
12 1999-12-31   5.585584   -0.268529   11.196275   
13 2000-12-31   8.415440    2.228004   14.076598   
14 2001-12-31   4.163283   -1.663638   10.041155   
15 2002-12-31   3.956459   -2.166535    9.212917   
16 2003-12-31   3.471408   -2.301298    9.377652   
17 2004-12-31   4.550043   -1.781218   10.681701   
18 2005-12-31   9.821040    3.868531   15.499418   
19 2006-12-31   6.193986   -0.221959   11.829260   
20 2007-12-31   2.002930   -3.631510    7.798222   
21 2008-12-31   2.435867   -3.400488    8.030518   
22 2009-12-31   1.020603   -4.851891    6.744770   
23 2010-12-31   2.328589   -3.114842    7.967965   
24 2011-12-31   7.660686    1.678133   13.342065   
25 2012-12-31   0.967389   -4.890986    6.717942   
26 2013-12-31   0.730118   -5.446970    6.241815   
27 2014-12-31   0.214413   -6.012026    5.784815   
28 2015-12-31  -1.139751   -7.214567    4.791593   
29 2016-12-31   6.625146    0.717754   12.638405   
30 2017-12-31   2.967645   -2.625725    8.929036   
31 2018-12-31  -1.254065   -7.419657    4.778922   
32 2019-12-31  -1.430236   -7.022282    4.188645   
33 2020-12-31  -2.175291   -8.133314    3.340915   
34 2021-12-31  -0.897752   -6.785047    5.006974   
35 2022-12-31   4.403692   -1.544194   10.595158   
36 2023-12-31   0.807291   -5.035938    6.779672   
37 2024-12-31  -2.465777   -8.181385    3.505412   
38 2025-12-31  -3.011928   -9.402865    2.812249   
39 2026-12-31  -4.396745  -10.559514    1.042678   
40 2027-12-31  -3.058105   -9.345763    2.516792   
41 2028-12-31  -0.228249   -6.062967    5.595024   
42 2029-12-31  -4.480406  -10.497465    0.771690   
43 2030-12-31  -4.687231  -10.551563    1.018345   

    Inflation_ConsumerPrice_Annual_Percentage  
0                                    7.233836  
1                                   18.811818  
2                                   18.245638  
3                                    3.052290  
4                                    3.556686  
5                                    6.353981  
6                                   14.610079  
7                                   24.256990  
8                                   16.791225  
9                                    8.313160  
10                                   2.786465  
11                                  -0.773186  
12                                  -1.401473  
13                                   0.347811  
14                                   0.719126  
15                                  -0.731971  
16                                   1.127603  
17                                   3.824637  
18                                   1.776414  
19                                   1.649431  
20                                   4.816768  
21                                   5.925251  
22                                  -0.728165  
23                                   3.175325  
24                                   5.553899  
25                                   2.619524  
26                                   2.621050  
27                                   1.921642  
28                                   1.437024  
29                                   2.000002  
30                                   1.593136  
31                                   2.074790  
32                                   2.899234  
33                                   2.419422  
34                                        NaN  
35                                        NaN  
36                                        NaN  
37                                        NaN  
38                                        NaN  
39                                        NaN  
40                                        NaN  
41                                        NaN  
42                                        NaN  
43                                        NaN  
In [ ]: