Modelisation de l’indice SP500 avec le modèle GARCH

library(quantmod)
library(tseries)
library(stats)
library(rugarch)
library(fGarch)
library(forecast)

chargement dee données

getSymbols("^GSPC", from = "200-01-01", to = "2023-10-30")
## [1] "GSPC"
head(GSPC)
##            GSPC.Open GSPC.High GSPC.Low GSPC.Close GSPC.Volume GSPC.Adjusted
## 1927-12-30     17.66     17.66    17.66      17.66           0         17.66
## 1928-01-03     17.76     17.76    17.76      17.76           0         17.76
## 1928-01-04     17.72     17.72    17.72      17.72           0         17.72
## 1928-01-05     17.55     17.55    17.55      17.55           0         17.55
## 1928-01-06     17.66     17.66    17.66      17.66           0         17.66
## 1928-01-09     17.50     17.50    17.50      17.50           0         17.50

On va travailler avec les valeurs ajuster

Donnees=GSPC$GSPC.Adjusted

visualisation

plot(Donnees)

On voit que la tendance est en hausse , la série n’est pas stationnaire , pas de saisonnalité, et présence de volatilités

Calcul des rendements et visualisation

R=dailyReturn(Donnees)
R=na.omit(R)
plot(R)

On voit que la série est stationnaire, des périodes de fortes volatilités ont tendance à être suivies par des périodes de faibles volatilités. Cela témoignage de la présence de la variance conditionneele c’est à dire l’hétéroscédasticité conditionnelle Donc on envisage le modèle GARCH/ARCH

Formulation

Le modèle GARCH(p,q) s’écrit:

\[ \sigma_t^2 = \omega + \sum_{i=1}^p \alpha_i \epsilon_{t-i}^2 + \sum_{j=1}^q \beta_j \sigma_{t-j}^2 \]

Où:

\(\sigma_t^2\) est la variance conditionnelle à t

\(\omega\) est le terme constant

\(\epsilon_{t-i}\) sont les termes d’erreurs passés

\(\alpha_i\) mesurent l’impact des chocs passés

\(\beta_j\) mesurent la persistance de la volatilité

adftest pour confirmer la stationnarité

adf.test(R)
## 
##  Augmented Dickey-Fuller Test
## 
## data:  R
## Dickey-Fuller = -29.201, Lag order = 28, p-value = 0.01
## alternative hypothesis: stationary

#fonction d’autocorrélation

acf(R)

Ce rendement ressemble à un bruit blanc aléatoire.

Analysons le carre du rendement

R2=R^2
acf(R2)

On observe une decroissance régulière, d’où la variance conditionnelle de R2 est constante en temps

specification du modèle

spec=ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(5, 1)))

Estimation des paramètres

modele_garch=ugarchfit(spec = spec, data = R2)

print(modele_garch)
## 
## *---------------------------------*
## *          GARCH Model Fit        *
## *---------------------------------*
## 
## Conditional Variance Dynamics    
## -----------------------------------
## GARCH Model  : sGARCH(5,1)
## Mean Model   : ARFIMA(1,0,1)
## Distribution : norm 
## 
## Optimal Parameters
## ------------------------------------
##         Estimate  Std. Error    t value Pr(>|t|)
## mu      0.000077    0.000001   55.29178 0.000000
## ar1     0.941738    0.003520  267.57302 0.000000
## ma1    -0.802623    0.004646 -172.76752 0.000000
## omega   0.000000    0.000000    0.01093 0.991279
## alpha1  0.010000    0.000313   31.94322 0.000000
## alpha2  0.010000    0.000864   11.57285 0.000000
## alpha3  0.010000    0.001409    7.09560 0.000000
## alpha4  0.010000    0.002482    4.02985 0.000056
## alpha5  0.010000    0.001985    5.03745 0.000000
## beta1   0.900007    0.000370 2433.53162 0.000000
## 
## Robust Standard Errors:
##         Estimate  Std. Error   t value Pr(>|t|)
## mu      0.000077    0.017596  0.004356  0.99652
## ar1     0.941738   80.689065  0.011671  0.99069
## ma1    -0.802623   97.872184 -0.008201  0.99346
## omega   0.000000    0.001316  0.000000  1.00000
## alpha1  0.010000    1.020153  0.009803  0.99218
## alpha2  0.010000    0.407220  0.024557  0.98041
## alpha3  0.010000    0.320426  0.031209  0.97510
## alpha4  0.010000    1.721228  0.005810  0.99536
## alpha5  0.010000    5.004762  0.001998  0.99841
## beta1   0.900007    1.860347  0.483785  0.62854
## 
## LogLikelihood : 168069.1 
## 
## Information Criteria
## ------------------------------------
##                     
## Akaike       -13.963
## Bayes        -13.960
## Shibata      -13.963
## Hannan-Quinn -13.962
## 
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
##                         statistic   p-value
## Lag[1]                      16.43 5.058e-05
## Lag[2*(p+q)+(p+q)-1][5]     16.74 0.000e+00
## Lag[4*(p+q)+(p+q)-1][9]     18.73 3.805e-07
## d.o.f=2
## H0 : No serial correlation
## 
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
##                          statistic p-value
## Lag[1]                       1.860  0.1726
## Lag[2*(p+q)+(p+q)-1][17]     1.895  0.9988
## Lag[4*(p+q)+(p+q)-1][29]     1.968  1.0000
## d.o.f=6
## 
## Weighted ARCH LM Tests
## ------------------------------------
##              Statistic Shape Scale P-Value
## ARCH Lag[7]   0.003858 0.500 2.000  0.9505
## ARCH Lag[9]   0.010174 1.485 1.796  0.9997
## ARCH Lag[11]  0.019438 2.440 1.677  1.0000
## 
## Nyblom stability test
## ------------------------------------
## Joint Statistic:  888.696
## Individual Statistics:              
## mu       2.256
## ar1      7.689
## ma1      3.382
## omega  236.388
## alpha1  28.554
## alpha2  31.055
## alpha3  28.065
## alpha4  27.487
## alpha5  27.029
## beta1   24.358
## 
## Asymptotic Critical Values (10% 5% 1%)
## Joint Statistic:          2.29 2.54 3.05
## Individual Statistic:     0.35 0.47 0.75
## 
## Sign Bias Test
## ------------------------------------
##                    t-value      prob sig
## Sign Bias           1.0397 2.985e-01    
## Negative Sign Bias  0.1688 8.660e-01    
## Positive Sign Bias  4.0978 4.185e-05 ***
## Joint Effect       21.1329 9.879e-05 ***
## 
## 
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
##   group statistic p-value(g-1)
## 1    20     20713            0
## 2    30     21486            0
## 3    40     22006            0
## 4    50     22347            0
## 
## 
## Elapsed time : 1.94999