Data Prog with Python
  • Introduction
  • Week2
  • Week3
  • Week4
  • Week5
  • Week6
  • Week7
  • Week8
  • Week9
  • Week10
  • project1
  • project2
  • project3
  • Useful codes for exam
Powered by GitBook
On this page
  • pandas
  • Rolling values
  • Stationary TS data
  • Correlation Functions
  • ARIMA: Auto-Regressive Integrated Moving Average

Was this helpful?

Week9

PreviousWeek8NextWeek10

Last updated 5 years ago

Was this helpful?

Time series

pandas

pd.to_datetime
pd.DataFrame
pd.DataFrame.set_index

Rolling values

timeseries.rolling_mean(window=k,center=False)
timeseries.rolling_std(window=k, center=False)

Stationary TS data

  • mean is not function of time

  • variance is not function of time

  • covariance of ith and i+m are not function of time

    How to check

  • Plotting Rolling Statistics

  • Dickey-Fuller Test

    from statsmodels.tsa.stattools import adfuller
    results=adfuller(TS data)

Correlation Functions

  • AutoCorrelation Function (ACF) [TS and lagged TS correlation]

  • Partial AutoCorrelation Function (PACF)

  • CrossCorrelation Function (CCF) self-similarity between two timeseries

from statsmodels.tsa.stattools import acf
from statsmodels.tsa.stattools import pacf
from statsmodels.tsa.stattools import ccf
lag_acf=acf(ts, nlags=NL)
lag_pacf=pacf(ts, nlags=NL)
lag_ccf=ccf(ts1,ts2)

ARIMA: Auto-Regressive Integrated Moving Average

Differencing: remove changes in the level of a TS, eliminting trend and consequently stabilizing the mean

yt=yt-y(t-1)

ARMA

ARIMA--integrated: be differenced

ARIMA(p,d,q)

import statsmodels.tsa.stattools as tsast
from statmodels.tsa.arima_model import ARIMA  
model=ARIMA(series, order(p,d,q))
model_fit=model.fit()
output=model_fit.forecast()

https://www.researchgate.net/file.PostFileLoader.html?id=5524f76cd3df3e2e7d8b4627&assetKey=AS:273752485498895@1442279086851
http://people.duke.edu/~rnau/Slides_on_ARIMA_models--Robert_Nau.pdf