최대 1 분 소요

[Notice] [Yearly]

ACF

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

import warnings
warnings.filterwarnings("ignore")

from statsmodels.tsa.stattools import adfuller
from statsmodels.tsa.stattools import acf, pacf
from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
df=pd.read_csv('https://raw.githubusercontent.com/sm-joo/sm-joo/master/DEXKOUS.csv', parse_dates=['DATE'], index_col='DATE')
df.columns=["KOUS"]
df['KOUS'].replace('.', '', inplace=True)
df['KOUS'] = pd.to_numeric(df['KOUS'])
df.fillna(method='ffill', inplace=True)

yearly

df.plot(figsize=(16,5))
<AxesSubplot:xlabel='DATE'>

df_w=df.resample('W-Fri').last()
df_2017 = df_w.loc[df_w.index.year==2017]
df_2019 = df_w.loc[df_w.index.year==2019]
df_2019.tail()
KOUS
DATE
2019-11-29 1181.33
2019-12-06 1189.86
2019-12-13 1171.97
2019-12-20 1160.30
2019-12-27 1160.87
df_2017.plot(figsize = (16, 6))
<AxesSubplot:xlabel='DATE'>

df_2019.plot(figsize = (16, 6))
<AxesSubplot:xlabel='DATE'>

plot_acf(df_2017)
plt.show()

plot_acf(df_2019)
plt.show()

# 1st row: raw series of 2017 data, ACF, PACF
# 2nd row: raw series of 2019 data, ACF, PACF
figure, axes = plt.subplots(2, 3, figsize=(16, 7))
axes[0,0].plot(df_2017)
axes[0,0].set_title('original series(2017)')
axes[1,0].plot(df_2019)
axes[1,0].set_title('original series(2019)')
plot_acf(df_2017, ax=axes[0,1])
plot_acf(df_2019, ax=axes[1,1])
plot_pacf(df_2017, ax=axes[0,2])
plot_pacf(df_2019, ax=axes[1,2])
plt.show()

  • Compared to 2017, the external shock lasted longer in 2019. 3 weeks -4 weeks

  • In 2017, the external shock remains 0.75 for the next period, but remains 0.9 for 2019. (The persistence is increasing.)

–> Subscriber, user marketing effect analysis

–> Stock index, exchange rate: How long the external shock lasts.

댓글남기기