ARCH/GARCH in R

library(tseries)
library(fGarch)
library(rugarch)
library(MASS)

fGarch package (functional but not my first choice)

ARCH/GARCH analysis in R was, in years past, primarily performed through the fGarch package, which offers model definition, prediction, plotting, etc. through familiar interfaces. The package is still maintained and offers solid support for basic and intermediate use cases.

Although not shown in the code below, the predict() method simultaneously predicts for both the mean and the variance (we are extracting only the variance).

fgarch.armagarch <- garchFit(SP500 ~ arma(1,1) + garch(1,1), data=SP500)

Series Initialization:
 ARMA Model:                arma
 Formula Mean:              ~ arma(1, 1)
 GARCH Model:               garch
 Formula Variance:          ~ garch(1, 1)
 ARMA Order:                1 1
 Max ARMA Order:            1
 GARCH Order:               1 1
 Max GARCH Order:           1
 Maximum Order:             1
 Conditional Dist:          norm
 h.start:                   2
 llh.start:                 1
 Length of Series:          2780
 Recursion Init:            mci
 Series Scale:              0.9477464
Warning in arima(.series$x, order = c(u, 0, v), include.mean = include.mean):
possible convergence problem: optim gave code = 1
Parameter Initialization:
 Initial Parameters:          $params
 Limits of Transformations:   $U, $V
 Which Parameters are Fixed?  $includes
 Parameter Matrix:
                     U           V      params includes
    mu     -0.48275223   0.4827522  0.04829772     TRUE
    ar1    -0.99999999   1.0000000 -0.17030411     TRUE
    ma1    -0.99999999   1.0000000  0.18933184     TRUE
    omega   0.00000100 100.0000000  0.10000000     TRUE
    alpha1  0.00000001   1.0000000  0.10000000     TRUE
    gamma1 -0.99999999   1.0000000  0.10000000    FALSE
    beta1   0.00000001   1.0000000  0.80000000     TRUE
    delta   0.00000000   2.0000000  2.00000000    FALSE
    skew    0.10000000  10.0000000  1.00000000    FALSE
    shape   1.00000000  10.0000000  4.00000000    FALSE
 Index List of Parameters to be Optimized:
    mu    ar1    ma1  omega alpha1  beta1 
     1      2      3      4      5      7 
 Persistence:                  0.9 


--- START OF TRACE ---
Selected Algorithm: nlminb 

R coded nlminb Solver: 

  0:     3707.8226: 0.0482977 -0.170304 0.189332 0.100000 0.100000 0.800000
  1:     3695.1512: 0.0483008 -0.169151 0.190394 0.0787674 0.103273 0.793089
  2:     3683.1731: 0.0483048 -0.167750 0.191673 0.0771166 0.122061 0.805435
  3:     3670.4420: 0.0483162 -0.164180 0.194885 0.0364971 0.141012 0.809289
  4:     3660.5110: 0.0483495 -0.155768 0.202148 0.0273841 0.154717 0.849936
  5:     3654.5379: 0.0484140 -0.147342 0.207997 0.00549702 0.128500 0.877750
  6:     3642.7519: 0.0485273 -0.135221 0.215353 0.0234248 0.0902875 0.885425
  7:     3633.9451: 0.0485836 -0.156626 0.189896 0.0136500 0.0797515 0.912497
  8:     3633.0063: 0.0485839 -0.156566 0.189943 0.0105706 0.0785118 0.911182
  9:     3631.5382: 0.0485888 -0.156336 0.189948 0.0110774 0.0774069 0.914531
 10:     3628.8437: 0.0486198 -0.155502 0.189330 0.00610671 0.0651190 0.931398
 11:     3628.8374: 0.0486200 -0.155467 0.189358 0.00690257 0.0652188 0.931793
 12:     3628.6730: 0.0486201 -0.155451 0.189370 0.00658121 0.0649747 0.931600
 13:     3628.5997: 0.0486210 -0.155299 0.189488 0.00669202 0.0641082 0.931629
 14:     3628.4960: 0.0486285 -0.155665 0.188738 0.00693647 0.0631391 0.932849
 15:     3628.3416: 0.0486403 -0.155732 0.188093 0.00658872 0.0618761 0.933853
 16:     3627.7023: 0.0487967 -0.146041 0.190608 0.00583606 0.0549905 0.941102
 17:     3627.6803: 0.0487968 -0.146045 0.190601 0.00569596 0.0549451 0.941058
 18:     3627.6708: 0.0487975 -0.146078 0.190535 0.00557499 0.0550521 0.941321
 19:     3627.6631: 0.0488039 -0.146242 0.190071 0.00541304 0.0547618 0.941502
 20:     3627.6405: 0.0488109 -0.146398 0.189590 0.00547456 0.0545710 0.941794
 21:     3627.6121: 0.0488414 -0.146682 0.187899 0.00534687 0.0538378 0.942507
 22:     3627.6109: 0.0488415 -0.146681 0.187896 0.00538884 0.0538604 0.942550
 23:     3627.6098: 0.0488430 -0.146647 0.187864 0.00536123 0.0538500 0.942546
 24:     3627.6089: 0.0488460 -0.146581 0.187797 0.00535714 0.0538544 0.942608
 25:     3627.6071: 0.0488527 -0.146427 0.187652 0.00533035 0.0538425 0.942600
 26:     3627.0126: 0.0582226 0.0691733 -0.0144367 0.00556139 0.0577318 0.939071
 27:     3626.9127: 0.0590365 0.0879504 -0.0393038 0.00579615 0.0551005 0.940415
 28:     3626.8679: 0.0577092 0.100899 -0.0568744 0.00483480 0.0520673 0.945062
 29:     3626.8128: 0.0559977 0.102990 -0.0584852 0.00482603 0.0520600 0.944805
 30:     3626.7555: 0.0542885 0.105033 -0.0606813 0.00516634 0.0527725 0.943858
 31:     3626.7335: 0.0545761 0.0799272 -0.0362296 0.00520082 0.0531745 0.943421
 32:     3626.7274: 0.0513309 0.0971461 -0.0517508 0.00521763 0.0532398 0.943295
 33:     3626.7245: 0.0527050 0.0870950 -0.0425974 0.00535179 0.0536743 0.942666
 34:     3626.7237: 0.0529863 0.0806323 -0.0359524 0.00527602 0.0533714 0.943089
 35:     3626.7234: 0.0525806 0.0860125 -0.0414312 0.00528154 0.0534703 0.942988
 36:     3626.7234: 0.0526617 0.0850928 -0.0404383 0.00529002 0.0534592 0.942980
 37:     3626.7234: 0.0526679 0.0850071 -0.0403745 0.00528744 0.0534593 0.942986
 38:     3626.7234: 0.0526638 0.0850516 -0.0404173 0.00528753 0.0534593 0.942986

Final Estimate of the Negative LLH:
 LLH:  3477.526    norm LLH:  1.250908 
          mu          ar1          ma1        omega       alpha1        beta1 
 0.049911944  0.085051577 -0.040417326  0.004749381  0.053459335  0.942985580 

R-optimhess Difference Approximated Hessian Matrix:
                mu        ar1         ma1         omega       alpha1
mu     -5487.50292  -270.4325    27.02373      792.2338     226.0816
ar1     -270.43248 -2546.3381 -2516.58109    -1623.7710    -426.8226
ma1       27.02373 -2516.5811 -2520.78590    -1624.0013    -415.2228
omega    792.23377 -1623.7710 -1624.00131 -1800871.1748 -629448.6023
alpha1   226.08164  -426.8226  -415.22283  -629448.6023 -357310.5359
beta1   -296.61877 -1036.8765  -969.35042  -803221.5863 -402755.4115
              beta1
mu        -296.6188
ar1      -1036.8765
ma1       -969.3504
omega  -803221.5863
alpha1 -402755.4115
beta1  -480647.1975
attr(,"time")
Time difference of 0.01929498 secs

--- END OF TRACE ---


Time to Estimate Parameters:
 Time difference of 0.1493778 secs
summary(fgarch.armagarch)

Title:
 GARCH Modelling 

Call:
 garchFit(formula = SP500 ~ arma(1, 1) + garch(1, 1), data = SP500) 

Mean and Variance Equation:
 data ~ arma(1, 1) + garch(1, 1)
<environment: 0x143254ca8>
 [data = SP500]

Conditional Distribution:
 norm 

Coefficient(s):
        mu         ar1         ma1       omega      alpha1       beta1  
 0.0499119   0.0850516  -0.0404173   0.0047494   0.0534593   0.9429856  

Std. Errors:
 based on Hessian 

Error Analysis:
        Estimate  Std. Error  t value Pr(>|t|)    
mu      0.049912    0.018630    2.679  0.00738 ** 
ar1     0.085052    0.237099    0.359  0.71981    
ma1    -0.040417    0.237614   -0.170  0.86493    
omega   0.004749    0.001664    2.853  0.00433 ** 
alpha1  0.053459    0.008028    6.659 2.75e-11 ***
beta1   0.942986    0.008508  110.839  < 2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Log Likelihood:
 -3477.526    normalized:  -1.250908 

Description:
 Thu Mar 12 22:57:53 2026 by user:  



Standardised Residuals Tests:
                                  Statistic    p-Value
 Jarque-Bera Test   R    Chi^2  743.5736024 0.00000000
 Shapiro-Wilk Test  R    W        0.9797477 0.00000000
 Ljung-Box Test     R    Q(10)   17.1068851 0.07203209
 Ljung-Box Test     R    Q(15)   28.6103664 0.01804608
 Ljung-Box Test     R    Q(20)   32.3070958 0.04013397
 Ljung-Box Test     R^2  Q(10)    5.6342460 0.84499961
 Ljung-Box Test     R^2  Q(15)    9.3117155 0.86066293
 Ljung-Box Test     R^2  Q(20)   12.1598580 0.91046386
 LM Arch Test       R    TR^2     8.7157933 0.72699462

Information Criterion Statistics:
     AIC      BIC      SIC     HQIC 
2.506134 2.518933 2.506124 2.510755 
# estimates of iid normal errors omega_t
(fgarch.omega <- head(residuals(fgarch.armagarch,standardize=TRUE)))
[1]  0.0000000 -0.9665403 -1.0755090  0.4782480 -1.3808938 -0.7108837
# estimates of past conditional sd sigma_t
(fgarch.sigma_past <- head(fgarch.armagarch@sigma.t))
[1] 0.9487024 0.9238347 0.9231379 0.9279241 0.9095212 0.9322778
# forecasts of future conditional sd sigma_t
(fgarch.sigma_future <- head(predict(fgarch.armagarch)[,3]))
[1] 1.585127 1.583807 1.582490 1.581178 1.579868 1.578563

fGARCH also allows the user to create fixed specifications which can be used for simulation purposes, and it has a nice array of diagnostic plotting tools with some user interactivity. The plots below come from a menu of 16 total diagnostics which the user can shuffle back and forth:

par(mfrow=c(2,2),mar=c(4,3,3,1)+0.1)
plot(fgarch.armagarch,which=c(2,3,7,11))

Ultimately, for student work, fGarch is more than enough “horsepower” for most jobs. I was tempted to use it for the two previous pages on ARCH and GARCH models. However, it has lost some industry support in favor of a newer package with more functionality and control.