Choosing the Right Model

Time Series Analysis in Python

Rob Reider

Adjunct Professor, NYU-Courant Consultant, Quantopian

Identifying the Order of an AR Model

  • The order of an AR(p) model will usually be unknown
  • Two techniques to determine order
    • Partial Autocorrelation Function
    • Information criteria
Time Series Analysis in Python

Partial Autocorrelation Function (PACF)

Time Series Analysis in Python

Plot PACF in Python

  • Same as ACF, but use plot_pacf instead of plt_acf
  • Import module
    from statsmodels.graphics.tsaplots import plot_pacf
    
  • Plot the PACF
    plot_pacf(x, lags= 20, alpha=0.05)
    
Time Series Analysis in Python

Comparison of PACF for Different AR Models

  • AR(1)

  • AR(3)

  • AR(2)

  • White Noise

Time Series Analysis in Python

Information Criteria

  • Information criteria: adjusts goodness-of-fit for number of parameters
  • Two popular adjusted goodness-of-fit measures
    • AIC (Akaike Information Criterion)
    • BIC (Bayesian Information Criterion)
Time Series Analysis in Python

Information Criteria

  • Estimation output
Time Series Analysis in Python

Getting Information Criteria From statsmodels

  • You learned earlier how to fit an AR model
    from statsmodels.tsa.arima_model import ARIMA
    mod = ARIMA(simulated_data, order=(1,0))
    result = mod.fit()
    
  • And to get full output
    result.summary()
    
  • Or just the parameters
    result.params
    
  • To get the AIC and BIC
    result.aic
    result.bic
    
Time Series Analysis in Python

Information Criteria

  • Fit a simulated AR(3) to different AR(p) models
  • Choose p with the lowest BIC
Time Series Analysis in Python

Let's practice!

Time Series Analysis in Python

Preparing Video For Download...