Git Product home page Git Product logo

dsc-arma-models-statsmodels-lab's Introduction

ARMA Models in StatsModels - Lab

Introduction

In this lesson, you'll fit an ARMA model using statsmodels to a real-world dataset.

Objectives

In this lab you will:

  • Decide the optimal parameters for an ARMA model by plotting ACF and PACF and interpreting them
  • Fit an ARMA model using StatsModels

Dataset

Run the cell below to import the dataset containing the historical running times for the men's 400m in the Olympic games.

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import warnings
from statsmodels.tools.sm_exceptions import ConvergenceWarning

warnings.simplefilter("ignore", ConvergenceWarning)

data = pd.read_csv("winning_400m.csv")
data["year"] = pd.to_datetime(data["year"].astype(str))
data.set_index("year", inplace=True)
data.index = data.index.to_period("Y")
# Preview the dataset
data

Plot this time series data.

# Plot the time series

If you plotted the time series correctly, you should notice that it is not stationary. So, difference the data to get a stationary time series. Make sure to remove the missing values.

# Difference the time series
data_diff = None
data_diff

Use statsmodels to plot the ACF and PACF of this differenced time series.

# Plot the ACF
# Plot the PACF

Based on the ACF and PACF, fit an ARMA model with the right orders for AR and MA. Feel free to try different models and compare AIC and BIC values, as well as significance values for the parameter estimates.

What is your final model? Why did you pick this model?

# Your comments here

Summary

Well done. In addition to manipulating and visualizing time series data, you now know how to create a stationary time series and fit ARMA models.

dsc-arma-models-statsmodels-lab's People

Contributors

hoffm386 avatar jessepisel avatar sumedh10 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.