library(quantmod)
library(tseries)
library(stats)
library(rugarch)
library(fGarch)
library(forecast)
getSymbols("^GSPC", from = "2000-01-01", to = "2023-10-30")
## [1] "GSPC"
head(GSPC)
## GSPC.Open GSPC.High GSPC.Low GSPC.Close GSPC.Volume GSPC.Adjusted
## 2000-01-03 1469.25 1478.00 1438.36 1455.22 931800000 1455.22
## 2000-01-04 1455.22 1455.22 1397.43 1399.42 1009000000 1399.42
## 2000-01-05 1399.42 1413.27 1377.68 1402.11 1085500000 1402.11
## 2000-01-06 1402.11 1411.90 1392.10 1403.45 1092300000 1403.45
## 2000-01-07 1403.45 1441.47 1400.73 1441.47 1225200000 1441.47
## 2000-01-10 1441.47 1464.36 1441.47 1457.60 1064800000 1457.60
On va travailler avec les valeurs ajuster
Donnees=GSPC$GSPC.Adjusted
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
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
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é
adf.test(R)
##
## Augmented Dickey-Fuller Test
##
## data: R
## Dickey-Fuller = -18.646, Lag order = 18, p-value = 0.01
## alternative hypothesis: stationary
#fonction d’autocorrélation
acf(R)
Ce rendement ressemble à un bruit blanc aléatoire.
R2=R^2
acf(R2)
On observe une decroissance régulière, d’où la variance conditionnelle de R2 est constante en temps
spec=ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(5, 1)))
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.000154 0.000026 5.838353 0.000000
## ar1 0.965476 0.003477 277.678845 0.000000
## ma1 -0.815184 0.009094 -89.642525 0.000000
## omega 0.000000 0.000000 0.009137 0.992710
## alpha1 0.010000 0.000283 35.330445 0.000000
## alpha2 0.010000 0.001260 7.937147 0.000000
## alpha3 0.010000 0.002656 3.765133 0.000166
## alpha4 0.010000 0.004636 2.157230 0.030988
## alpha5 0.010000 0.001337 7.482106 0.000000
## beta1 0.900000 0.009762 92.198942 0.000000
##
## Robust Standard Errors:
## Estimate Std. Error t value Pr(>|t|)
## mu 0.000154 0.274487 0.000559 0.99955
## ar1 0.965476 28.624844 0.033729 0.97309
## ma1 -0.815184 135.137345 -0.006032 0.99519
## omega 0.000000 0.000422 0.000001 1.00000
## alpha1 0.010000 17.047709 0.000587 0.99953
## alpha2 0.010000 18.905925 0.000529 0.99958
## alpha3 0.010000 7.348321 0.001361 0.99891
## alpha4 0.010000 5.452487 0.001834 0.99854
## alpha5 0.010000 68.901489 0.000145 0.99988
## beta1 0.900000 164.936099 0.005457 0.99565
##
## LogLikelihood : 41745.96
##
## Information Criteria
## ------------------------------------
##
## Akaike -13.926
## Bayes -13.915
## Shibata -13.926
## Hannan-Quinn -13.922
##
## Weighted Ljung-Box Test on Standardized Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 10.82 1.005e-03
## Lag[2*(p+q)+(p+q)-1][5] 20.65 0.000e+00
## Lag[4*(p+q)+(p+q)-1][9] 22.32 3.509e-09
## d.o.f=2
## H0 : No serial correlation
##
## Weighted Ljung-Box Test on Standardized Squared Residuals
## ------------------------------------
## statistic p-value
## Lag[1] 8.716 0.003155
## Lag[2*(p+q)+(p+q)-1][17] 25.407 0.000440
## Lag[4*(p+q)+(p+q)-1][29] 27.819 0.008563
## d.o.f=6
##
## Weighted ARCH LM Tests
## ------------------------------------
## Statistic Shape Scale P-Value
## ARCH Lag[7] 0.009864 0.500 2.000 0.9209
## ARCH Lag[9] 0.085807 1.485 1.796 0.9919
## ARCH Lag[11] 3.265690 2.440 1.677 0.5479
##
## Nyblom stability test
## ------------------------------------
## Joint Statistic: 414.8473
## Individual Statistics:
## mu 0.13154
## ar1 0.18234
## ma1 0.07932
## omega 90.12560
## alpha1 11.97786
## alpha2 15.93501
## alpha3 17.21551
## alpha4 17.51122
## alpha5 16.05006
## beta1 10.43788
##
## 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 2.800 0.005123 ***
## Negative Sign Bias 1.802 0.071539 *
## Positive Sign Bias 1.222 0.221669
## Joint Effect 13.426 0.003800 ***
##
##
## Adjusted Pearson Goodness-of-Fit Test:
## ------------------------------------
## group statistic p-value(g-1)
## 1 20 4338 0
## 2 30 4558 0
## 3 40 4711 0
## 4 50 4910 0
##
##
## Elapsed time : 0.2881711