Theory


Skew-t-EGARCH-in-mean models follow the same basis as the Beta-t-EGARCH-in-mean model, but have scores for the skew-t distribution and the skew-t distributional assumption for the residuals.

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 pandas.io.data import DataReader
from datetime import datetime
import matplotlib.pyplot as plt
%matplotlib inline 

aapl = DataReader('AAPL',  'yahoo', datetime(2006,1,1), datetime(2016,3,10))
returns = pd.DataFrame(np.diff(np.log(aapl['Adj Close'].values)))
returns.index = aapl.index.values[1:aapl.index.values.shape[0]]
returns.columns = ['AAPL Returns']

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

Now let’s fit the EGARCH-in-mean model with the skew-t formulation:

skewt_model = pf.SEGARCHM(p=1,q=1,data=returns,target='AAPL Returns')
x = skewt_model.fit()
x.summary()
SEGARCHM(1,1)                                                                                             
======================================================= =================================================
Dependent Variable: AAPL Returns                        Method: MLE                                       
Start Date: 2006-01-05 00:00:00                         Log Likelihood: 6547.0586                         
End Date: 2016-03-10 00:00:00                           AIC: -13080.1172                                  
Number of observations: 2562                            BIC: -13039.1774                                  
=========================================================================================================
Latent Variable                          Estimate   Std Error  z        P>|z|    95% C.I.                 
======================================== ========== ========== ======== ======== ========================
Vol Constant                             -0.2917    0.0074     -39.3318 0.0      (-0.3063 | -0.2772)      
p(1)                                     0.9653                                                           
q(1)                                     0.1354                                                           
Skewness                                 0.9201                                                           
v                                        6.7153                                                           
Returns Constant                         0.0028     0.0001     19.4147  0.0      (0.0025 | 0.0031)        
GARCH-M                                  0.362      0.1235     2.9323   0.0034   (0.12 | 0.604)           
=========================================================================================================

We can plot the Skew-t GARCH-M latent variable with plot_z:

skewt_model.plot_z([6],figsize=(15,5))
png

So we have a risk-premium associated with the stock. Let’s plot the fit with plot_fit:

skewt_model.plot_fit(figsize=(15,5))
png

And obtain predictions of future conditional volatility with predict:

skewt_model.predict(h=10)
AAPL Returns
2016-03-07 0.012506
2016-03-10 0.012585
2016-03-11 0.012661
2016-03-12 0.012735
2016-03-13 0.012807
2016-03-14 0.012877
2016-03-17 0.012944
2016-03-18 0.013010
2016-03-19 0.013074
2016-03-20 0.013136

Or plot the results with plot_predict:

skewt_model.plot_predict(h=10,figsize=(15,5))
png