1.
2 FRAM
                                         2023-11-26
Part 1.3 - GARCH and EGARCH models
Company - VIPCLOTHING Time Frame - DAILY
require(quantmod)
## Loading required package: quantmod
## Loading required package: xts
## Loading required package: zoo
##
## Attaching package: ’zoo’
## The following objects are masked from ’package:base’:
##
##     as.Date, as.Date.numeric
## Loading required package: TTR
## Registered S3 method overwritten by ’quantmod’:
##   method            from
##   as.zoo.data.frame zoo
library(rugarch)
## Loading required package: parallel
##
## Attaching package: ’rugarch’
## The following object is masked from ’package:stats’:
##
##     sigma
#### GARCH & EGARCH Models for VIPCLOTHNG.NS ####
# Data Collection
VIPCLOTHNG <- getSymbols("VIPCLOTHNG.NS", from = "2020-11-02", to = "2023-10-26", auto.assign = FALSE)
## Warning: VIPCLOTHNG.NS contains missing values. Some functions will not work if
## objects contain missing values in the middle of the series. Consider using
## na.omit(), na.approx(), na.fill(), etc to remove or replace them.
                                             1
head(VIPCLOTHNG)
##                VIPCLOTHNG.NS.Open VIPCLOTHNG.NS.High VIPCLOTHNG.NS.Low
##   2020-11-02                 8.95               9.10              8.70
##   2020-11-03                 8.95               8.95              8.65
##   2020-11-04                 8.65               8.85              8.50
##   2020-11-05                 8.65               8.75              8.50
##   2020-11-06                 8.50               8.90              8.50
##   2020-11-09                 8.60               8.75              8.50
##                VIPCLOTHNG.NS.Close VIPCLOTHNG.NS.Volume VIPCLOTHNG.NS.Adjusted
##   2020-11-02                  8.75                35156                   8.75
##   2020-11-03                  8.75                22822                   8.75
##   2020-11-04                  8.70                39265                   8.70
##   2020-11-05                  8.60                25793                   8.60
##   2020-11-06                  8.60                42164                   8.60
##   2020-11-09                  8.55                21833                   8.55
# Extracting closing prices
VIPCLOTHNG_Close <- Cl(VIPCLOTHNG)
# Return Calculation
returns_vipclothng <- dailyReturn(VIPCLOTHNG_Close)
## Warning in to_period(xx, period = on.opts[[period]], ...): missing values
## removed from data
# Implementing Univariate GARCH
ug_spec = ugarchspec()
ug_spec
##
##   *---------------------------------*
##   *       GARCH Model Spec          *
##   *---------------------------------*
##
##   Conditional Variance Dynamics
##   ------------------------------------
##   GARCH Model      : sGARCH(1,1)
##   Variance Targeting   : FALSE
##
##   Conditional Mean Dynamics
##   ------------------------------------
##   Mean Model       : ARFIMA(1,0,1)
##   Include Mean     : TRUE
##   GARCH-in-Mean        : FALSE
##
##   Conditional Distribution
##   ------------------------------------
##   Distribution : norm
##   Includes Skew    : FALSE
##   Includes Shape   : FALSE
##   Includes Lambda : FALSE
                                                2
# Implementing EGARCH
eg_spec = ugarchspec(variance.model = list(model="eGARCH"))
eg_spec
##
##   *---------------------------------*
##   *       GARCH Model Spec          *
##   *---------------------------------*
##
##   Conditional Variance Dynamics
##   ------------------------------------
##   GARCH Model      : eGARCH(1,1)
##   Variance Targeting   : FALSE
##
##   Conditional Mean Dynamics
##   ------------------------------------
##   Mean Model       : ARFIMA(1,0,1)
##   Include Mean     : TRUE
##   GARCH-in-Mean        : FALSE
##
##   Conditional Distribution
##   ------------------------------------
##   Distribution : norm
##   Includes Skew    : FALSE
##   Includes Shape   : FALSE
##   Includes Lambda : FALSE
# Estimating the models
ugfit_vipclothng = ugarchfit(spec = ug_spec, data = returns_vipclothng)
ugfit_vipclothng
##
##   *---------------------------------*
##   *          GARCH Model Fit        *
##   *---------------------------------*
##
##   Conditional Variance Dynamics
##   -----------------------------------
##   GARCH Model : sGARCH(1,1)
##   Mean Model   : ARFIMA(1,0,1)
##   Distribution : norm
##
##   Optimal Parameters
##   ------------------------------------
##           Estimate Std. Error t value     Pr(>|t|)
##   mu      0.002192    0.001165 1.88199    0.059837
##   ar1     0.248934    0.156039 1.59533    0.110637
##   ma1    -0.064090    0.160416 -0.39952   0.689510
##   omega   0.000051    0.000024 2.08485    0.037083
##   alpha1 0.153596     0.037074 4.14293    0.000034
##   beta1   0.793257    0.054150 14.64933   0.000000
##
##   Robust Standard Errors:
                                                3
##          Estimate    Std. Error t value Pr(>|t|)
##   mu     0.002192      0.001236 1.77326 0.076185
##   ar1    0.248934      0.120816 2.06044 0.039357
##   ma1   -0.064090      0.124940 -0.51296 0.607977
##   omega  0.000051      0.000030 1.68796 0.091418
##   alpha1 0.153596      0.032717 4.69470 0.000003
##   beta1  0.793257      0.058899 13.46807 0.000000
##
##   LogLikelihood : 1591.986
##
##   Information Criteria
##   ------------------------------------
##
##   Akaike         -4.2981
##   Bayes          -4.2606
##   Shibata        -4.2982
##   Hannan-Quinn   -4.2836
##
##   Weighted Ljung-Box Test on Standardized Residuals
##   ------------------------------------
##                           statistic p-value
##   Lag[1]                     0.7439 0.3884
##   Lag[2*(p+q)+(p+q)-1][5]    3.6247 0.1597
##   Lag[4*(p+q)+(p+q)-1][9]    6.0433 0.2495
##   d.o.f=2
##   H0 : No serial correlation
##
##   Weighted Ljung-Box Test on Standardized Squared Residuals
##   ------------------------------------
##                           statistic p-value
##   Lag[1]                     0.4478 0.5034
##   Lag[2*(p+q)+(p+q)-1][5]    1.6607 0.7004
##   Lag[4*(p+q)+(p+q)-1][9]    3.8437 0.6154
##   d.o.f=2
##
##   Weighted ARCH LM Tests
##   ------------------------------------
##               Statistic Shape Scale P-Value
##   ARCH Lag[3]     1.435 0.500 2.000 0.2309
##   ARCH Lag[5]     1.724 1.440 1.667 0.5354
##   ARCH Lag[7]     3.232 2.315 1.543 0.4709
##
##   Nyblom stability test
##   ------------------------------------
##   Joint Statistic: 1.2291
##   Individual Statistics:
##   mu     0.26393
##   ar1    0.09305
##   ma1    0.10640
##   omega 0.36595
##   alpha1 0.11201
##   beta1 0.18128
##
##   Asymptotic Critical Values (10% 5% 1%)
                                                 4
##   Joint Statistic:            1.49 1.68 2.12
##   Individual Statistic:       0.35 0.47 0.75
##
##   Sign Bias Test
##   ------------------------------------
##                      t-value   prob sig
##   Sign Bias          0.63219 0.5275
##   Negative Sign Bias 0.07133 0.9432
##   Positive Sign Bias 1.46263 0.1440
##   Joint Effect       2.35943 0.5012
##
##
##   Adjusted Pearson Goodness-of-Fit Test:
##   ------------------------------------
##     group statistic p-value(g-1)
##   1    20     44.01    0.0009427
##   2    30     60.05    0.0006091
##   3    40     66.44    0.0039821
##   4    50     80.70    0.0029128
##
##
##   Elapsed time : 0.08433294
egfit_vipclothng = ugarchfit(spec = eg_spec, data = returns_vipclothng)
egfit_vipclothng
##
##   *---------------------------------*
##   *          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.002774    0.001737 1.59715    0.110231
##   ar1     0.250542    0.122626 2.04314    0.041039
##   ma1    -0.062802    0.126853 -0.49508   0.620546
##   omega -0.480214     0.188755 -2.54411   0.010956
##   alpha1 0.064347     0.030767 2.09141    0.036492
##   beta1   0.933259    0.026289 35.49985   0.000000
##   gamma1 0.222122     0.057755 3.84594    0.000120
##
##   Robust Standard Errors:
##           Estimate Std. Error t value Pr(>|t|)
##   mu      0.002774    0.002355 1.17765 0.238938
##   ar1     0.250542    0.084279 2.97278 0.002951
##   ma1    -0.062802    0.083386 -0.75315 0.451359
##   omega -0.480214     0.221908 -2.16402 0.030463
                                                  5
##   alpha1   0.064347    0.028428 2.26347 0.023607
##   beta1    0.933259    0.031095 30.01300 0.000000
##   gamma1   0.222122    0.057673 3.85143 0.000117
##
##   LogLikelihood : 1597.562
##
##   Information Criteria
##   ------------------------------------
##
##   Akaike         -4.3105
##   Bayes          -4.2668
##   Shibata        -4.3106
##   Hannan-Quinn   -4.2936
##
##   Weighted Ljung-Box Test on Standardized Residuals
##   ------------------------------------
##                           statistic p-value
##   Lag[1]                     0.2182 0.6404
##   Lag[2*(p+q)+(p+q)-1][5]    3.3367 0.2798
##   Lag[4*(p+q)+(p+q)-1][9]    5.7843 0.2934
##   d.o.f=2
##   H0 : No serial correlation
##
##   Weighted Ljung-Box Test on Standardized Squared Residuals
##   ------------------------------------
##                           statistic p-value
##   Lag[1]                      0.489 0.4844
##   Lag[2*(p+q)+(p+q)-1][5]     2.224 0.5665
##   Lag[4*(p+q)+(p+q)-1][9]     4.769 0.4642
##   d.o.f=2
##
##   Weighted ARCH LM Tests
##   ------------------------------------
##               Statistic Shape Scale P-Value
##   ARCH Lag[3]     2.349 0.500 2.000 0.1254
##   ARCH Lag[5]     2.780 1.440 1.667 0.3233
##   ARCH Lag[7]     4.438 2.315 1.543 0.2877
##
##   Nyblom stability test
##   ------------------------------------
##   Joint Statistic: 1.0615
##   Individual Statistics:
##   mu     0.28199
##   ar1    0.07627
##   ma1    0.09068
##   omega 0.07745
##   alpha1 0.25647
##   beta1 0.08800
##   gamma1 0.18207
##
##   Asymptotic Critical Values (10% 5% 1%)
##   Joint Statistic:          1.69 1.9 2.35
##   Individual Statistic:     0.35 0.47 0.75
##
                                                 6
##   Sign Bias Test
##   ------------------------------------
##                      t-value   prob sig
##   Sign Bias           0.3675 0.7134
##   Negative Sign Bias 0.5216 0.6021
##   Positive Sign Bias 0.9553 0.3397
##   Joint Effect        1.1999 0.7530
##
##
##   Adjusted Pearson Goodness-of-Fit Test:
##   ------------------------------------
##     group statistic p-value(g-1)
##   1    20     28.02      0.08312
##   2    30     38.91      0.10339
##   3    40     52.68      0.07063
##   4    50     71.35      0.02022
##
##
##   Elapsed time : 0.2032249
# Forecasting
ugforecast_vipclothng = ugarchforecast(ugfit_vipclothng, n.ahead=10)
ugforecast_vipclothng
##
##   *------------------------------------*
##   *       GARCH Model Forecast         *
##   *------------------------------------*
##   Model: sGARCH
##   Horizon: 10
##   Roll Steps: 0
##   Out of Sample: 0
##
##   0-roll forecast   [T0=2023-10-25]:
##            Series     Sigma
##   T+1 -0.0030145    0.04418
##   T+2   0.0008958   0.04357
##   T+3   0.0018692   0.04299
##   T+4   0.0021115   0.04243
##   T+5   0.0021718   0.04190
##   T+6   0.0021868   0.04138
##   T+7   0.0021906   0.04089
##   T+8   0.0021915   0.04042
##   T+9   0.0021917   0.03997
##   T+10 0.0021918    0.03954
egforecast_vipclothng = ugarchforecast(egfit_vipclothng, n.ahead=10)
egforecast_vipclothng
##
## *------------------------------------*
## *       GARCH Model Forecast         *
## *------------------------------------*
                                              7
##   Model: eGARCH
##   Horizon: 10
##   Roll Steps: 0
##   Out of Sample: 0
##
##   0-roll forecast [T0=2023-10-25]:
##           Series   Sigma
##   T+1 -0.002605 0.03139
##   T+2   0.001426 0.03111
##   T+3   0.002436 0.03085
##   T+4   0.002689 0.03060
##   T+5   0.002752 0.03038
##   T+6   0.002768 0.03017
##   T+7   0.002772 0.02997
##   T+8   0.002773 0.02979
##   T+9   0.002773 0.02963
##   T+10 0.002773 0.02947