Feeds:
Posts

## CAN ANYTHING BEAT A GARCH(1,1) MODEL?

The Gold Standard of volatility prediction is the GARCH(1,1) model. Here we show that using aggregate market volatility significantly improves the log-likelihood of the fit in-sample for volatility prediction of individual stocks. For this exercise, we use the excellent R package ‘rugarch’. One way of looking at this volatility prediction problem is that since the ARCH model of Engle (1982) and the GARCH model of Bollerslev (1986) there’s been thirty years of tweaking univariate models for volatility prediction; this is a mature field. My own belief is that there’s not much technical tweaking that can yield great new insights about univariate models and I am providing a complementary view of where improvements can come from. I ask the question: what is the most predictable volatility? It is the aggregate volatility of the entire market. Therefore the right sort of thing to do is to set this as an EXTERNAL REGRESSOR into the GARCH or other univariate model. So watch a few things below. First, the change in the log-likelihood where model 1 is the EGARCH (I chose eGARCH because there are fewer annoyances regarding positivity constraints of the standard GARCH). Unfortunately rugarch fitting procedures often have convergence problems so I am reporting here only the fits that converged among a pool of ~1900 stocks). Second, watch for the coefficient, standard error and p-value for the vxreg1 parameter in model 2. This is essentially the change in the aggregate volatility used as an external regressor.

Let’s start with an example where things did not go our way — an insignificant p-value for the external regressor, so our model is not a universal panacea, but below more common examples of where there is a strong in-sample improvement.

```[1] "---------------------------------------"
[1] "Stock:  TRAK"
[1] "model1"

*---------------------------------*
*          GARCH Model Fit        *
*---------------------------------*

Conditional Variance Dynamics
-----------------------------------
GARCH Model	: eGARCH(1,1)
Mean Model	: ARFIMA(1,0,1)
Distribution	: norm

Optimal Parameters
------------------------------------
Estimate  Std. Error   t value Pr(>|t|)
mu      0.000166    0.000026    6.3801        0
ar1    -0.342971    0.017658  -19.4233        0
ma1     0.404225    0.017122   23.6089        0
omega  -0.247254    0.003759  -65.7786        0
alpha1 -0.134196    0.013746   -9.7628        0
beta1   0.962510    0.000421 2284.3569        0
gamma1  0.182365    0.021155    8.6203        0

Robust Standard Errors:
Estimate  Std. Error   t value Pr(>|t|)
mu      0.000166    0.000086    1.9337 0.053154
ar1    -0.342971    0.011615  -29.5270 0.000000
ma1     0.404225    0.011228   36.0001 0.000000
omega  -0.247254    0.018006  -13.7320 0.000000
alpha1 -0.134196    0.047306   -2.8368 0.004557
beta1   0.962510    0.000487 1976.3724 0.000000
gamma1  0.182365    0.066333    2.7492 0.005974

LogLikelihood : 5361.089

Information Criteria
------------------------------------

Akaike       -4.4048
Bayes        -4.3882
Shibata      -4.4049
Hannan-Quinn -4.3988

Weighted Ljung-Box Test on Standardized Residuals
------------------------------------
statistic p-value
Lag[1]                     0.4553  0.4998
Lag[2*(p+q)+(p+q)-1][5]    2.3369  0.8567
Lag[4*(p+q)+(p+q)-1][9]    3.6345  0.7733
d.o.f=2
H0 : No serial correlation

Weighted Ljung-Box Test on Standardized Squared Residuals
------------------------------------
statistic p-value
Lag[1]                   0.009686  0.9216
Lag[2*(p+q)+(p+q)-1][5]  0.125512  0.9970
Lag[4*(p+q)+(p+q)-1][9]  0.252253  0.9998
d.o.f=2

Weighted ARCH LM Tests
------------------------------------
Statistic Shape Scale P-Value
ARCH Lag[3]   0.04527 0.500 2.000  0.8315
ARCH Lag[5]   0.15852 1.440 1.667  0.9750
ARCH Lag[7]   0.22958 2.315 1.543  0.9960

Nyblom stability test
------------------------------------
Joint Statistic:  3.2335
Individual Statistics:
mu     0.05646
ar1    0.06747
ma1    0.07119
omega  0.09758
alpha1 1.10457
beta1  0.08708
gamma1 0.06659

Asymptotic Critical Values (10% 5% 1%)
Joint Statistic:     	 1.69 1.9 2.35
Individual Statistic:	 0.35 0.47 0.75

Sign Bias Test
------------------------------------
t-value   prob sig
Sign Bias          0.06366 0.9492
Negative Sign Bias 0.50413 0.6142
Positive Sign Bias 0.49391 0.6214
Joint Effect       0.99547 0.8023

------------------------------------
group statistic p-value(g-1)
1    20     228.9    5.661e-38
2    30     238.1    1.013e-34
3    40     248.2    2.867e-32
4    50     263.1    4.412e-31

Elapsed time : 0.6193271

[1] "model2"

*---------------------------------*
*          GARCH Model Fit        *
*---------------------------------*

Conditional Variance Dynamics
-----------------------------------
GARCH Model	: eGARCH(1,1)
Mean Model	: ARFIMA(1,0,1)
Distribution	: norm

Optimal Parameters
------------------------------------
Estimate  Std. Error     t value Pr(>|t|)
mu      0.000161    0.000026    6.205142  0.00000
ar1    -0.342009    0.018085  -18.911416  0.00000
ma1     0.403435    0.017505   23.046233  0.00000
omega  -0.247032    0.004041  -61.137282  0.00000
alpha1 -0.134140    0.013762   -9.746987  0.00000
beta1   0.962548    0.000338 2845.980583  0.00000
gamma1  0.182591    0.021762    8.390284  0.00000
vxreg1 -0.001917    0.021468   -0.089283  0.92886

Robust Standard Errors:
Estimate  Std. Error     t value Pr(>|t|)
mu      0.000161    0.000087    1.855757 0.063488
ar1    -0.342009    0.012456  -27.458165 0.000000
ma1     0.403435    0.012074   33.414465 0.000000
omega  -0.247032    0.017142  -14.411033 0.000000
alpha1 -0.134140    0.047291   -2.836477 0.004561
beta1   0.962548    0.000324 2973.108981 0.000000
gamma1  0.182591    0.068931    2.648896 0.008076
vxreg1 -0.001917    0.051349   -0.037327 0.970224

LogLikelihood : 5361.093

Information Criteria
------------------------------------

Akaike       -4.4040
Bayes        -4.3850
Shibata      -4.4040
Hannan-Quinn -4.3971

Weighted Ljung-Box Test on Standardized Residuals
------------------------------------
statistic p-value
Lag[1]                     0.4597  0.4977
Lag[2*(p+q)+(p+q)-1][5]    2.3417  0.8547
Lag[4*(p+q)+(p+q)-1][9]    3.6371  0.7727
d.o.f=2
H0 : No serial correlation

Weighted Ljung-Box Test on Standardized Squared Residuals
------------------------------------
statistic p-value
Lag[1]                   0.009567  0.9221
Lag[2*(p+q)+(p+q)-1][5]  0.125424  0.9970
Lag[4*(p+q)+(p+q)-1][9]  0.252344  0.9998
d.o.f=2

Weighted ARCH LM Tests
------------------------------------
Statistic Shape Scale P-Value
ARCH Lag[3]   0.04523 0.500 2.000  0.8316
ARCH Lag[5]   0.15864 1.440 1.667  0.9749
ARCH Lag[7]   0.22976 2.315 1.543  0.9960

Nyblom stability test
------------------------------------
Joint Statistic:  3.3439
Individual Statistics:
mu     0.05595
ar1    0.06763
ma1    0.07128
omega  0.09716
alpha1 1.10454
beta1  0.08668
gamma1 0.06626
vxreg1 0.10168

Asymptotic Critical Values (10% 5% 1%)
Joint Statistic:     	 1.89 2.11 2.59
Individual Statistic:	 0.35 0.47 0.75

Sign Bias Test
------------------------------------
t-value   prob sig
Sign Bias          0.06522 0.9480
Negative Sign Bias 0.50289 0.6151
Positive Sign Bias 0.49366 0.6216
Joint Effect       0.99553 0.8023

------------------------------------
group statistic p-value(g-1)
1    20     229.4    4.402e-38
2    30     236.9    1.733e-34
3    40     247.7    3.588e-32
4    50     261.2    9.936e-31

Elapsed time : 1.035142

[1] "---------------------------------------"
[1] "Stock:  TRAK"
[1] "model1"

*---------------------------------*
*          GARCH Model Fit        *
*---------------------------------*

Conditional Variance Dynamics
-----------------------------------
GARCH Model	: eGARCH(1,1)
Mean Model	: ARFIMA(1,0,1)
Distribution	: norm

Optimal Parameters
------------------------------------
Estimate  Std. Error   t value Pr(>|t|)
mu      0.000166    0.000026    6.3801        0
ar1    -0.342971    0.017658  -19.4233        0
ma1     0.404225    0.017122   23.6089        0
omega  -0.247254    0.003759  -65.7786        0
alpha1 -0.134196    0.013746   -9.7628        0
beta1   0.962510    0.000421 2284.3569        0
gamma1  0.182365    0.021155    8.6203        0

Robust Standard Errors:
Estimate  Std. Error   t value Pr(>|t|)
mu      0.000166    0.000086    1.9337 0.053154
ar1    -0.342971    0.011615  -29.5270 0.000000
ma1     0.404225    0.011228   36.0001 0.000000
omega  -0.247254    0.018006  -13.7320 0.000000
alpha1 -0.134196    0.047306   -2.8368 0.004557
beta1   0.962510    0.000487 1976.3724 0.000000
gamma1  0.182365    0.066333    2.7492 0.005974

LogLikelihood : 5361.089

Information Criteria
------------------------------------

Akaike       -4.4048
Bayes        -4.3882
Shibata      -4.4049
Hannan-Quinn -4.3988

Weighted Ljung-Box Test on Standardized Residuals
------------------------------------
statistic p-value
Lag[1]                     0.4553  0.4998
Lag[2*(p+q)+(p+q)-1][5]    2.3369  0.8567
Lag[4*(p+q)+(p+q)-1][9]    3.6345  0.7733
d.o.f=2
H0 : No serial correlation

Weighted Ljung-Box Test on Standardized Squared Residuals
------------------------------------
statistic p-value
Lag[1]                   0.009686  0.9216
Lag[2*(p+q)+(p+q)-1][5]  0.125512  0.9970
Lag[4*(p+q)+(p+q)-1][9]  0.252253  0.9998
d.o.f=2

Weighted ARCH LM Tests
------------------------------------
Statistic Shape Scale P-Value
ARCH Lag[3]   0.04527 0.500 2.000  0.8315
ARCH Lag[5]   0.15852 1.440 1.667  0.9750
ARCH Lag[7]   0.22958 2.315 1.543  0.9960

Nyblom stability test
------------------------------------
Joint Statistic:  3.2335
Individual Statistics:
mu     0.05646
ar1    0.06747
ma1    0.07119
omega  0.09758
alpha1 1.10457
beta1  0.08708
gamma1 0.06659

Asymptotic Critical Values (10% 5% 1%)
Joint Statistic:     	 1.69 1.9 2.35
Individual Statistic:	 0.35 0.47 0.75

Sign Bias Test
------------------------------------
t-value   prob sig
Sign Bias          0.06366 0.9492
Negative Sign Bias 0.50413 0.6142
Positive Sign Bias 0.49391 0.6214
Joint Effect       0.99547 0.8023

------------------------------------
group statistic p-value(g-1)
1    20     228.9    5.661e-38
2    30     238.1    1.013e-34
3    40     248.2    2.867e-32
4    50     263.1    4.412e-31

Elapsed time : 0.6193271

[1] "model2"

*---------------------------------*
*          GARCH Model Fit        *
*---------------------------------*

Conditional Variance Dynamics
-----------------------------------
GARCH Model	: eGARCH(1,1)
Mean Model	: ARFIMA(1,0,1)
Distribution	: norm

Optimal Parameters
------------------------------------
Estimate  Std. Error     t value Pr(>|t|)
mu      0.000161    0.000026    6.205142  0.00000
ar1    -0.342009    0.018085  -18.911416  0.00000
ma1     0.403435    0.017505   23.046233  0.00000
omega  -0.247032    0.004041  -61.137282  0.00000
alpha1 -0.134140    0.013762   -9.746987  0.00000
beta1   0.962548    0.000338 2845.980583  0.00000
gamma1  0.182591    0.021762    8.390284  0.00000
vxreg1 -0.001917    0.021468   -0.089283  0.92886

Robust Standard Errors:
Estimate  Std. Error     t value Pr(>|t|)
mu      0.000161    0.000087    1.855757 0.063488
ar1    -0.342009    0.012456  -27.458165 0.000000
ma1     0.403435    0.012074   33.414465 0.000000
omega  -0.247032    0.017142  -14.411033 0.000000
alpha1 -0.134140    0.047291   -2.836477 0.004561
beta1   0.962548    0.000324 2973.108981 0.000000
gamma1  0.182591    0.068931    2.648896 0.008076
vxreg1 -0.001917    0.051349   -0.037327 0.970224

LogLikelihood : 5361.093

Information Criteria
------------------------------------

Akaike       -4.4040
Bayes        -4.3850
Shibata      -4.4040
Hannan-Quinn -4.3971

Weighted Ljung-Box Test on Standardized Residuals
------------------------------------
statistic p-value
Lag[1]                     0.4597  0.4977
Lag[2*(p+q)+(p+q)-1][5]    2.3417  0.8547
Lag[4*(p+q)+(p+q)-1][9]    3.6371  0.7727
d.o.f=2
H0 : No serial correlation

Weighted Ljung-Box Test on Standardized Squared Residuals
------------------------------------
statistic p-value
Lag[1]                   0.009567  0.9221
Lag[2*(p+q)+(p+q)-1][5]  0.125424  0.9970
Lag[4*(p+q)+(p+q)-1][9]  0.252344  0.9998
d.o.f=2

Weighted ARCH LM Tests
------------------------------------
Statistic Shape Scale P-Value
ARCH Lag[3]   0.04523 0.500 2.000  0.8316
ARCH Lag[5]   0.15864 1.440 1.667  0.9749
ARCH Lag[7]   0.22976 2.315 1.543  0.9960

Nyblom stability test
------------------------------------
Joint Statistic:  3.3439
Individual Statistics:
mu     0.05595
ar1    0.06763
ma1    0.07128
omega  0.09716
alpha1 1.10454
beta1  0.08668
gamma1 0.06626
vxreg1 0.10168

Asymptotic Critical Values (10% 5% 1%)
Joint Statistic:     	 1.89 2.11 2.59
Individual Statistic:	 0.35 0.47 0.75

Sign Bias Test
------------------------------------
t-value   prob sig
Sign Bias          0.06522 0.9480
Negative Sign Bias 0.50289 0.6151
Positive Sign Bias 0.49366 0.6216
Joint Effect       0.99553 0.8023

------------------------------------
group statistic p-value(g-1)
1    20     229.4    4.402e-38
2    30     236.9    1.733e-34
3    40     247.7    3.588e-32
4    50     261.2    9.936e-31

Elapsed time : 1.035142

Now as promised, and example where our external regressor provides an improvement in log-likelihood in-sample, from 18558.02 to 18603.57, which is quite a strong improvement.
[1] "Stock:  RSH"
[1] "model1"

*---------------------------------*
*          GARCH Model Fit        *
*---------------------------------*

Conditional Variance Dynamics
-----------------------------------
GARCH Model	: eGARCH(1,1)
Mean Model	: ARFIMA(1,0,1)
Distribution	: norm

Optimal Parameters
------------------------------------
Estimate  Std. Error     t value Pr(>|t|)
mu      0.000206    0.000230     0.89952 0.368374
ar1    -0.110436    0.030956    -3.56749 0.000360
ma1     0.143623    0.030664     4.68382 0.000003
omega  -0.020145    0.000498   -40.45013 0.000000
alpha1 -0.033024    0.003530    -9.35562 0.000000
beta1   0.996344    0.000018 54581.44139 0.000000
gamma1  0.077537    0.000234   331.54384 0.000000

Robust Standard Errors:
Estimate  Std. Error     t value Pr(>|t|)
mu      0.000206    0.000303     0.68258 0.494870
ar1    -0.110436    0.007869   -14.03402 0.000000
ma1     0.143623    0.006812    21.08296 0.000000
omega  -0.020145    0.001330   -15.15101 0.000000
alpha1 -0.033024    0.009250    -3.57007 0.000357
beta1   0.996344    0.000062 16068.43735 0.000000
gamma1  0.077537    0.001240    62.52807 0.000000

LogLikelihood : 18558.02

Information Criteria
------------------------------------

Akaike       -4.4701
Bayes        -4.4642
Shibata      -4.4701
Hannan-Quinn -4.4681

Weighted Ljung-Box Test on Standardized Residuals
------------------------------------
statistic p-value
Lag[1]                      1.082  0.2983
Lag[2*(p+q)+(p+q)-1][5]     2.376  0.8395
Lag[4*(p+q)+(p+q)-1][9]     3.494  0.8025
d.o.f=2
H0 : No serial correlation

Weighted Ljung-Box Test on Standardized Squared Residuals
------------------------------------
statistic p-value
Lag[1]                      6.557 0.01044
Lag[2*(p+q)+(p+q)-1][5]     8.297 0.02485
Lag[4*(p+q)+(p+q)-1][9]     9.599 0.06102
d.o.f=2

Weighted ARCH LM Tests
------------------------------------
Statistic Shape Scale P-Value
ARCH Lag[3]     1.711 0.500 2.000  0.1908
ARCH Lag[5]     1.842 1.440 1.667  0.5071
ARCH Lag[7]     2.328 2.315 1.543  0.6481

Nyblom stability test
------------------------------------
Joint Statistic:  3.6278
Individual Statistics:
mu     0.5330
ar1    0.5562
ma1    0.5639
omega  1.5110
alpha1 0.3379
beta1  1.4078
gamma1 1.9356

Asymptotic Critical Values (10% 5% 1%)
Joint Statistic:     	 1.69 1.9 2.35
Individual Statistic:	 0.35 0.47 0.75

Sign Bias Test
------------------------------------
t-value     prob sig
Sign Bias            1.903 0.057129   *
Negative Sign Bias   1.234 0.217244
Positive Sign Bias   3.659 0.000255 ***
Joint Effect        15.517 0.001424 ***

------------------------------------
group statistic p-value(g-1)
1    20     379.0    1.013e-68
2    30     425.6    4.733e-72
3    40     500.7    1.757e-81
4    50     514.3    7.926e-79

Elapsed time : 2.2473

[1] "model2"

*---------------------------------*
*          GARCH Model Fit        *
*---------------------------------*

Conditional Variance Dynamics
-----------------------------------
GARCH Model	: eGARCH(1,1)
Mean Model	: ARFIMA(1,0,1)
Distribution	: norm

Optimal Parameters
------------------------------------
Estimate  Std. Error     t value Pr(>|t|)
mu      0.000178    0.000233     0.76176 0.446203
ar1    -0.114620    0.051051    -2.24522 0.024754
ma1     0.146114    0.050768     2.87805 0.004001
omega  -0.054416    0.000702   -77.55581 0.000000
alpha1 -0.034021    0.003914    -8.69234 0.000000
beta1   0.991746    0.000098 10171.32444 0.000000
gamma1  0.090681    0.001587    57.15700 0.000000
vxreg1 -0.092825    0.009187   -10.10424 0.000000

Robust Standard Errors:
Estimate  Std. Error    t value Pr(>|t|)
mu      0.000178    0.000306    0.57985 0.562018
ar1    -0.114620    0.012745   -8.99300 0.000000
ma1     0.146114    0.013788   10.59692 0.000000
omega  -0.054416    0.002443  -22.27691 0.000000
alpha1 -0.034021    0.010105   -3.36690 0.000760
beta1   0.991746    0.000306 3239.51728 0.000000
gamma1  0.090681    0.003477   26.07954 0.000000
vxreg1 -0.092825    0.025544   -3.63386 0.000279

LogLikelihood : 18603.57

Information Criteria
------------------------------------

Akaike       -4.4809
Bayes        -4.4741
Shibata      -4.4809
Hannan-Quinn -4.4785

Weighted Ljung-Box Test on Standardized Residuals
------------------------------------
statistic p-value
Lag[1]                      1.886  0.1697
Lag[2*(p+q)+(p+q)-1][5]     3.016  0.4620
Lag[4*(p+q)+(p+q)-1][9]     4.037  0.6823
d.o.f=2
H0 : No serial correlation

Weighted Ljung-Box Test on Standardized Squared Residuals
------------------------------------
statistic  p-value
Lag[1]                      7.713 0.005482
Lag[2*(p+q)+(p+q)-1][5]     9.372 0.013318
Lag[4*(p+q)+(p+q)-1][9]    10.365 0.041863
d.o.f=2

Weighted ARCH LM Tests
------------------------------------
Statistic Shape Scale P-Value
ARCH Lag[3]     1.423 0.500 2.000  0.2329
ARCH Lag[5]     1.452 1.440 1.667  0.6049
ARCH Lag[7]     2.117 2.315 1.543  0.6926

Nyblom stability test
------------------------------------
Joint Statistic:  3.0967
Individual Statistics:
mu     0.36873
ar1    0.70263
ma1    0.71070
omega  1.07370
alpha1 0.21085
beta1  1.05749
gamma1 1.03259
vxreg1 0.02065

Asymptotic Critical Values (10% 5% 1%)
Joint Statistic:     	 1.89 2.11 2.59
Individual Statistic:	 0.35 0.47 0.75

Sign Bias Test
------------------------------------
t-value      prob sig
Sign Bias            2.332 0.0197468  **
Negative Sign Bias   1.153 0.2491002
Positive Sign Bias   3.891 0.0001005 ***
Joint Effect        17.795 0.0004849 ***

------------------------------------
group statistic p-value(g-1)
1    20     351.2    5.691e-63
2    30     395.9    5.032e-66
3    40     476.4    1.328e-76
4    50     507.3    1.894e-77

Elapsed time : 2.359505

Now for a scan of the p-values of the aggregate volatility fit from models we grep 'vxreg1' so that each triplet of lines represents a different stock and the first of the triplet has the p-value in the third column.  So from the sample of 42 stocks picked, the rate of 'miss' defined as insignificant p-value for the external regressor is 5, so 88% in this sample of stocks the aggregate volatility is a significant factor for volatility.  The code for this test follows so it is transparent what I am doing.
vxreg1  0.186185    0.013905    13.3899  0.00000
vxreg1  0.186185    0.050223    3.7072 0.000210
vxreg1 0.41820
vxreg1  0.021053    0.006909  3.0474e+00 0.002308
vxreg1  0.021053    0.015404  1.3667e+00 0.171719
vxreg1 0.08641
vxreg1 -0.172842    0.059919  -2.88460 0.003919
vxreg1 -0.172842    0.236681  -0.73027 0.465223
vxreg1 0.13063
vxreg1  0.037353    0.009407     3.9708 0.000072
vxreg1  0.037353    0.015863     2.3547 0.018535
vxreg1 0.07455
vxreg1 -0.021720    0.010140   -2.14202 0.032192
vxreg1 -0.021720    0.028153   -0.77152  0.44040
vxreg1 0.03079
vxreg1 -0.077716    0.031401 -2.47492 0.013327
vxreg1 -0.077716    0.107926 -0.72009 0.471471
vxreg1 0.06165
vxreg1  0.293797    0.020115  14.6056  0.00000
vxreg1  0.293797    0.137241  2.14074 0.032295
vxreg1 0.12176
vxreg1  0.054257    0.015052   3.6047 0.000312
vxreg1  0.054257    0.022505   2.4108 0.015916
vxreg1 0.03022
vxreg1  0.076413    0.018477   4.1357 0.000035
vxreg1  0.076413    0.026798   2.85142 0.004352
vxreg1 0.09924
vxreg1  0.055100    0.019372   2.84437 0.004450
vxreg1  0.055100    0.030190   1.82514  0.06798
vxreg1 0.04733
vxreg1  0.062678    0.014601   4.2927 0.000018
vxreg1  0.062678    0.036022   1.7400 0.081860
vxreg1 0.06064
vxreg1 -0.092825    0.009187   -10.10424 0.000000
vxreg1 -0.092825    0.025544   -3.63386 0.000279
vxreg1 0.02065
vxreg1 -0.014370    0.008011    -1.79391 0.072828
vxreg1 -0.014370    0.030662    -0.46868  0.63930
vxreg1 0.05782
vxreg1  0.004249    0.026392   0.1610 0.872095 <<<<-- miss
vxreg1  0.004249    0.052188   0.081418 0.935110
vxreg1 0.2006
vxreg1 -0.001917    0.021468   -0.089283  0.92886
vxreg1 -0.001917    0.051349   -0.037327 0.970224
vxreg1 0.10168
vxreg1  0.051259    0.011129    4.60605 0.000004
vxreg1  0.051259    0.015583    3.28949 0.001004
vxreg1 0.03167
vxreg1  0.025410    0.013864   1.8328 0.066840
vxreg1  0.025410    0.016343   1.5548 0.119996
vxreg1 0.03529
vxreg1  0.050113    0.008118     6.17310  0.00000
vxreg1  0.050113    0.011535     4.34439 0.000014
vxreg1 0.02671
vxreg1  0.089974    0.011974  7.5141e+00 0.000000
vxreg1  0.089974    0.032329  2.7831e+00 0.005385
vxreg1 0.12266
vxreg1 -0.004882    0.017484   -0.279232  0.78007 <<<<-- miss
vxreg1 -0.004882    0.055401  -0.088123 0.929779
vxreg1 0.2712
vxreg1 -0.080264    0.015145   -5.2996 0.000000
vxreg1 -0.080264    0.081716   -0.98223  0.32599
vxreg1 0.02797
vxreg1  0.105647    0.017394    6.0737 0.000000
vxreg1  0.105647    0.039145   2.6989 0.006958
vxreg1 0.07466
vxreg1  0.033132    0.018450   1.79577 0.072532
vxreg1  0.033132    0.078941   0.41970  0.67470
vxreg1 0.20812
vxreg1  0.053376    0.018608   2.86844 0.004125
vxreg1  0.053376    0.026439    2.01888 0.043500
vxreg1 0.0304
vxreg1  0.007951    0.012797    0.62133 0.534383 <<<<-- miss
vxreg1  0.007951    0.022305    0.35647 0.721490
vxreg1 0.07374
vxreg1 -0.020500    0.011010   -1.8619 0.062624
vxreg1 -0.020500    0.044032   -0.46556 0.641530
vxreg1 0.03728
vxreg1  0.035823    0.006865    5.21849 0.000000
vxreg1  0.035823    0.058931   0.60788 0.543265
vxreg1 0.02491
vxreg1  0.029358    0.007729  3.7986e+00 0.000146
vxreg1  0.029358    0.017321     1.69495 0.090084
vxreg1 0.12411
vxreg1  0.042496    0.020697   2.0533 0.040044
vxreg1  0.042496    0.058340   0.72843 0.466353
vxreg1 0.19193
vxreg1 -0.471775    0.022600 -20.8751 0.000000
vxreg1 -0.471775    0.096832  -4.8721 0.000001
vxreg1 0.2152
vxreg1 -0.023158    0.017685 -1.3094e+00  0.19039 <<<<-- miss
vxreg1 -0.023158    0.060169 -3.8488e-01 0.700328
vxreg1 0.1338
vxreg1  0.051991    0.016983      3.0614 0.002203
vxreg1  0.051991    0.020185     2.5757 0.010004
vxreg1 0.0733
vxreg1  0.021012    0.007999  2.6268e+00 0.008619
vxreg1  0.021012    0.018085  1.1618e+00  0.24531
vxreg1 0.01963
vxreg1  0.041945    0.008156  5.1429e+00  0.00000
vxreg1  0.041945    0.021563      1.9453 0.051741
vxreg1 0.18925
vxreg1  0.048565    0.005842      8.3135  0.00000
vxreg1  0.048565    0.019167      2.5338 0.011282
vxreg1 0.14782
vxreg1  0.031007    0.013768    2.252049 0.024319
vxreg1  0.031007    0.063287   0.489946 0.624172
vxreg1 0.008016
vxreg1 -0.014046    0.011003   -1.2767  0.20172 <<<<-- miss
vxreg1 -0.014046    0.032579   -0.43115 0.666359
vxreg1 0.01787
vxreg1  0.053225    0.016463   3.23291 0.001225
vxreg1  0.053225    0.052624   1.0114 0.311820
vxreg1 0.08392
vxreg1  0.083952    0.010890    7.70914 0.000000
vxreg1  0.083952    0.027768    3.02336 0.002500
vxreg1 0.04125
vxreg1  0.072676    0.010344    7.02578  0.00000
vxreg1  0.072676    0.021098    3.44475 0.000572
vxreg1 0.09703
vxreg1  0.091055    0.006867     13.2600 0.000000
vxreg1  0.091055    0.015017      6.0636  0.00000
vxreg1 0.06027
vxreg1  0.034151    0.009807     3.4824 0.000497
vxreg1  0.034151    0.019860    1.7196 0.085514
vxreg1 0.1380

R code:
library(Quandl)
library(rugarch)

getGlobalAggregateVolatility<-function(){

ntimes<-dim(P)[1]
nassets<-dim(P)[2]-2

aggvol<-rep(0,ntimes)
numnonna<-rep(0,ntimes)

for (k in 3:nassets){
if (class(P[,k])=="factor"){
next
}
r<-diff(log(P[,k]))
r[is.na(r)]<-0
for (j in 2:ntimes){
if (!is.na(r[j])){
v<-log(r[j]^2+1e-6)
if (abs(v)<100){
numnonna[j]<- numnonna[j]+1
aggvol[j]<-aggvol[j] + v
}
}
}
}

for (j in 1:length(aggvol)){
aggvol[j]<-aggvol[j]/numnonna[j]
}

dts<-as.character(P[,2])
daggvol<-diff(aggvol)
n<-length(daggvol)
globalaggvol<-xts(order.by=as.Date(tail(dts,n)),daggvol)
return (globalaggvol)
}

aggvol<-getGlobalAggregateVolatility()

ntimes<-dim(P)[1]
nassets<-dim(P)[2]-2

for (j in 3:(2+nassets)){

pseries<-P[,j]
r<-diff(log(pseries))
av<-aggvol[!is.na(r)]
r<-r[!is.na(r)]
stock<-colnames(P)[j]
stock<-sub("WIKI.","",stock,perl=TRUE)

print('---------------------------------------')
print(paste('Stock: ', stock))
#print(length(r))
if (length(r)<400){
next
}
model1<-ugarchspec( variance.model = list(model="eGARCH",
garchOrder=c(1,1)))
model2<-ugarchspec( variance.model = list(model="eGARCH",
garchOrder=c(1,1),external.regressors=as.matrix(av)))
mean.model<-list(armaOrder=c(0,0),include.mean=FALSE,
distributional.model="norm")

possibleError<-tryCatch({
model1fit<-ugarchfit(spec=model1,data=r)
model2fit<-ugarchfit(spec=model2,data=r)

spec1<-getspec(model1fit)
spec2<-getspec(model2fit)

print('model1')
show(model1fit)

print('model2')
show(model2fit)

setfixed(spec1)<-as.list(coef(model1fit))
setfixed(spec2)<-as.list(coef(model2fit))
refit.window="moving",solver="hybrid")
refit.window="moving",solver="hybrid")

print(names(P)[j])
print('Forecast1')
show(forecast1)
print('Forecast2')
show(forecast2)
},error=function(e)e)

if (inherits(possibleError,"error")) next

}

__ATA.cmd.push(function() {
__ATA.initVideoSlot('atatags-370373-5b30a2276c6ae', {
sectionId: '370373',
});
});

__ATA.cmd.push(function() {
__ATA.initSlot('atatags-26942-5b30a2276c6de',  {
collapseEmpty: 'before',
sectionId: '26942',
width: 300,
height: 250
});
});

__ATA.cmd.push(function() {
__ATA.initSlot('atatags-114160-5b30a2276c6e0',  {
collapseEmpty: 'before',
sectionId: '114160',
width: 300,
height: 250
});
});