## Theory

Introducing a long-term and a short-term component into the Beta-t-EGARCH framework allows for the conditional volatility series to exhibit long memory, which is a feature of many financial time series, as first discussed by Mandelbrot in the 1960s:

$y_{t} = \mu + \exp\left(\lambda_{t\mid{t-1}}/2\right)\epsilon_{t}$

$\lambda_{t\mid{t-1}} = \omega + \lambda_{1, t\mid{t-1}} + \lambda_{2, t\mid{t-1}}$

$\lambda_{1, t\mid{t-1}} = \sum^{p}_{i=1}\alpha_{1,i}\lambda_{1,t-i} + \sum^{q}_{j=1}\beta_{1,j}u_{t-j}$

$\lambda_{2, t\mid{t-1}} = \sum^{p}_{i=1}\alpha_{2,i}\lambda_{2,t-i} + \sum^{q}_{j=1}\beta_{2,j}u_{t-j}$

$\epsilon_{t} \sim t_{\nu}$

We require $\alpha_{1} \neq \alpha_{2}$ for identifiability.

## PyFlux

First let us load some financial time series data from Yahoo Finance:

import numpy as np
import pyflux as pf
import pandas as pd
from datetime import datetime
import matplotlib.pyplot as plt
%matplotlib inline

jpm = DataReader('JPM',  'yahoo', datetime(2006,1,1), datetime(2016,3,10))
returns.index = jpm.index.values[1:jpm.index.values.shape[0]]
returns.columns = ['JPM Returns']

plt.figure(figsize=(15,5));
plt.plot(returns.index,returns);
plt.ylabel('Returns');
plt.title('JPM Returns');

Let’s fit an Long Memory Beta-t-EGARCH model to the series:

model = pf.LMEGARCH(returns,p=1,q=1)
x = model.fit()
x.summary()
LMEGARCH(1,1)
======================================================= =================================================
Dependent Variable: JPM Returns                         Method: MLE
Start Date: 2006-01-05 00:00:00                         Log Likelihood: 6660.3439
End Date: 2016-03-10 00:00:00                           AIC: -13306.6879
Number of observations: 2562                            BIC: -13265.748
=========================================================================================================
Latent Variable                          Estimate   Std Error  z        P>|z|    95% C.I.
======================================== ========== ========== ======== ======== ========================
Vol Constant                             -9.263     0.6113     -15.1536 0.0      (-10.4611 | -8.0649)
Component 1 p(1)                         0.2491
Component 1 q(1)                         0.0476
Component 2 p(1)                         1.0
Component 2 q(1)                         0.0935
v                                        6.095
Returns Constant                         0.0008     0.0386     0.0195   0.9844   (-0.075 | 0.0765)
=========================================================================================================

We can plot the fit with plot_fit:

model.plot_fit(figsize=(15,5))

And obtain predictions of future conditional volatility with predict:

model.predict(h=10)
JPM Returns
2016-03-07 0.017464
2016-03-10 0.017759
2016-03-11 0.017833
2016-03-12 0.017851
2016-03-13 0.017856
2016-03-14 0.017857
2016-03-17 0.017857
2016-03-18 0.017857
2016-03-19 0.017857
2016-03-20 0.017857

Or plot the results with plot_predict:

model.plot_predict(h=10,figsize=(15,5))