This package contains R codes and data for producing results in the paper "R-estimators in GARCH models; asymptotics and applications ", 2020, Hang Liu and Kanchan Mukherjee. The following steps illustrate how to obtain those results.
Step 1. You need to install "Rcpp" and "RcppArmadillo" R packages to source the file "RankGarch.cpp" using R code: sourceCpp("RobEst.cpp”). You also need to install the software "Rtools" to source "RankGarch.cpp".
Step 2. In R programme, source the file "RankGarch.cpp". Note that "RankGarch.cpp" contains functions to compute R-estimators (based on the van der Waerden, Spearman and sign scores) and the QMLE for GARCH(1, 1). Specifically, "Resti" is a function to compute R-estimators for GARCH(1, 1) models; "QMLEesti" is a function to compute the QMLE of Mukherjee (2008) for GARCH(1, 1) models. Therefore, once "RankGarch.cpp" is sourced in R programme, you can use those functions.
Step 3. Read real data from a file and compute the log-returns, or simulate samples from a GARCH model with pre-specified true parameter and underlying innovation distribution.
Step 4. Use functions, such as "Resti", from the file "RankGarch.cpp" to compute the R-estimators of the scalar-transformed parameter $\theta_{0\varphi}$.
Step 5. Estimate the unknown scalar factor $c_\varphi$ and therefore the R-estimators of the true parameter. For example, one can obtain an estimate $\hat{c}_\varphi$ of $c_\varphi$ for the GARCH(1, 1) model using function “c_vp” in the file "RestGARCHsim.R". Then a R-estimator of the true parameter can be obtained by dividing the $\omega$ and $\alpha$ components by $\hat{c}_\varphi$.
More specifically, "RestGARCHrealdata.R" provides examples of analysing real data using the R-estimators, and "EFCX.csv", "SP.csv" and "GBPUSD.csv" are three real datasets that are used in this paper. Those R codes can be used to produce results in Table 1. One can use the datasets that we provided to produce results in different panels of Table 1. For example, if you want to get results for the S\&P 500 data, you can use the code “read.csv("SP.csv", ...)” to replace “read.csv("EFCX.csv", ...)”. You can also get results for GBP/USD using “read.csv("GBPUSD.csv", ...)”. The QMLE is based on the "fGarch” package in R. For the purpose of comparison, we also include the codes for computing the QMLE and LAD estimator of Mukherjee (2020, Bootstrapping M-estimators in generalized autoregressive conditional heteroscedastic models, Biometrika, 107, pp. 753-760). Moreover, we provide codes for Q-Q plots of the residuals against $t$ distributions in the lines 71-113. More specifically, the lines 71-90 can produce Q-Q plots for the EFCX data; the lines 94-113 can produce Q-Q plots for the S\&P 500 data.
"RestGARCHsim.R" gives codes showing how to obtain the R-estimators and QMLE under various error distributions for the GARCH(1, 1) models. One can use those R codes to produce results similar to Table 2 and Table C.1. Variables such as “Wil_hat”, “Sign_hat” and “vdW_hat” are the Wilcoxon, sign and vdW R-estimators of the true GARCH parameter, respectively; “MSE_Wil”, “MSE_Sign” and “MSE_vdW” are their MSEs, respectively. Note that by following the instructions in the file "RestGARCHsim.R", one can simulate GARCH(1, 1) models under various error distributions by simply adding or deleting “#” in the lines 46-65. For example, to produce various error distributions in Table 2, one can use code in the line 57 to generate random samples from the standard normal distribution; the lines 46-54 corresponds to the standardised double exponential distribution; the lines 60-61 corresponds to the standardised logistic distribution; lines 64-65 contains codes for the standardised $t(3)$ distribution. We set seed in line 43 and the seed number is the number of each replication (from 1 to 1000).
“ReprodFig1.R” gives codes to produce results similar to Figure 1. We simulated GARCH data by generating the errors from the normal and skew normal distributions. The codes mainly consist of three parts: 1). simulate GARCH(1, 1) models under the normal and skew normal innovations and to obtain the vdW R-estimates and QMLE; 2) obtain the R-estimates of Andrews (2012); 3) compute the MSE ratios and produce boxplots of the R-estimates and QMLE. To reproduce the upper panel using the "ReprodFig.R" file, please replace the normal distribution in line 40 by the skew normal distribution in lines 44-46 (line 44 is to estimate the mean of the skew normal distribution, line 45 is to simulate the skew normal innovations, line 46 is to demean the innovations). The skew normal distribution can be generated by setting ``nu = Inf" in ``rst" function, for which we need to have ``sn" R package installed (see lines 18-19). We set seed in line 37 and the seed number is varying with the identity number of each replication (from 1 to R=1000).
Copyright: @Hang Liu