Last active
August 5, 2020 01:27
-
-
Save pkgandhi/721d7bf5c18924f5d3e115be10d62ead to your computer and use it in GitHub Desktop.
Fitting the AR and MA Models
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Loading the packages | |
import pandas as pd | |
from statsmodels.tsa.statespace.sarimax import SARIMAX | |
# Loading the data | |
data = pd.read_csv('https://raw.githubusercontent.com/jbrownlee/Datasets/master/airline-passengers.csv') | |
# Setting the month as index | |
data = data.set_index('Month') | |
# Plot the data | |
data.plot() | |
# Achieving stationarity: | |
data_log_transformation = np.log(data) | |
data_rolling_avg = data_log_transformation.rolling(window = 12).mean() | |
(data_log_transformation - data_rolling_avg).plot() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment