Skip to content

Instantly share code, notes, and snippets.

@arimitramaiti
Created October 2, 2020 14:59
Show Gist options
  • Save arimitramaiti/87e9644e5e554e7853d22f8764652000 to your computer and use it in GitHub Desktop.
Save arimitramaiti/87e9644e5e554e7853d22f8764652000 to your computer and use it in GitHub Desktop.
#Import basic modules
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
import scipy.stats as stats
import math
import statsmodels.api as sm
##module for ADF Test in Python
from statsmodels.tsa.stattools import adfuller
##Import data
url = "https://raw.githubusercontent.com/arimitramaiti/datasets/master/articles/a5_data.csv"
dataset = pd.read_csv(url, error_bad_lines=False, header=0, index_col=None)
##Create the grid
fig, axes = plt.subplots(2, 2, figsize=(14,8))
fig.subplots_adjust(top=0.7)
sns.lineplot(data=dataset.GDP_pc, ax=axes[0,0]);
axes[0,0].set_title('U.S.A GDP Per Capita '+'\n\n'+"ADF Test:p-value: "+str(round(adfuller(dataset.GDP_pc)[1],3))+" Failure to Reject Null-Not Stationary")
axes[0,0].set_xlabel('Time Point', fontsize=11, weight='bold')
axes[0,0].set_ylabel("GDP Per Capita-Dollars", fontsize=11, weight='bold')
axes[0,0].spines['right'].set_visible(False)
axes[0,0].spines['top'].set_visible(False)
sns.lineplot(data=dataset.GDP_GWR, ax=axes[0,1]);
axes[0,1].set_title('U.S.A GDP Growth Rate '+'\n\n'+"ADF Test:p-value: "+str(round(adfuller(dataset.GDP_GWR)[1],3))+" Reject Null-Stationary")
axes[0,1].set_xlabel('Time Point', fontsize=11, weight='bold')
axes[0,1].set_ylabel("Growth Rate", fontsize=11, weight='bold')
axes[0,1].spines['right'].set_visible(False)
axes[0,1].spines['top'].set_visible(False)
sns.lineplot(data=dataset.Consumption/1000000, ax=axes[1,0]);
axes[1,0].set_title('U.S.A Consumption Expenses '+'\n\n '+"ADF Test:p-value: "+str(round(adfuller(dataset.Consumption)[1],3))+" Failure to Reject Null-Not Stationary")
axes[1,0].set_xlabel('Time Point', fontsize=11, weight='bold')
axes[1,0].set_ylabel("Consumption Expenses-Million Dollars", fontsize=11, weight='bold')
axes[1,0].spines['right'].set_visible(False)
axes[1,0].spines['top'].set_visible(False)
sns.lineplot(data=dataset.C_GWR, ax=axes[1,1]);
axes[1,1].set_title('U.S.A Consumption Growth Rate '+'\n\n'+"ADF Test:p-value: "+str(round(adfuller(dataset.C_GWR)[1],3))+" Reject Null-Stationary")
axes[1,1].set_xlabel('Time Point', fontsize=11, weight='bold')
axes[1,1].set_ylabel("Growth Rate", fontsize=11, weight='bold')
axes[1,1].spines['right'].set_visible(False)
axes[1,1].spines['top'].set_visible(False)
fig.tight_layout()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment