Time Series Analysis of the Daily stock returns of Dell Computer Corporation from October 1993 to October 1998.

Djanga Gildas
library(tseries)
library("nortest")
library("fGarch")
library(moments)   # for skewness, kurtosis
library(dplyr)     # for data manipulation
library(tibble)    # for tidy tables
source("C:\\Users\\UPCLASS TECHNOLOGY\\Desktop\\Actuarial Science 2 Q2\\Time series\\Time Series SHomework\\Homework_2_TS\\FonctionsSeriesChrono.R")

# Data loading 

Rt <- ts(read.table('C:\\Users\\UPCLASS TECHNOLOGY\\Downloads\\dell (1).txt'))

#View(Rt) 

Rt2 <- Rt^2
require(kableExtra)

options(digits = 3, knitr.kable.NA = '')

tbl <- function(data, ...) {
  data |> kbl(booktabs = TRUE, linesep = "", ...)  |> 
    kable_styling(latex_options = c("scale_down"))
}

Introduction

Understanding and modeling the dynamic behavior of high-frequency financial return time series is essential due to their unique characteristics, which distinguish them from other types of time series data. These distinguishing traits are commonly known in finance as the three stylized facts: long-range dependence, fat-tail property, and volatility clustering effect. The volatility clustering effect is first noted by Mandelbrot \((1963)\), where it is submitted that a Large changes tend to be followed by large changes, of either sign, and small changes tend to be followed by small changes. Fama \((1970)\) states that large price changes are followed by large price changes, but of unpredictable sign. Mandelbrot \((1963)\) also observes that asset returns are highly leptokurtic and slightly asymmetric. To model these dynamics particularly volatility clustering Engle \((1982)\) introduced the autoregressive conditional heteroskedasticity (ARCH) model, which was later extended by Bollerslev \((1986)\) into the generalized ARCH (GARCH) model. These models were among the first to effectively estimate conditional volatility using standard forms with normally distributed (Gaussian) innovations successfully capture volatility clustering.

This study is motivated by the availability of high-frequency time series return data which is the daily stock returns of dell Computer Corporation from October 1993 to October 1998 and the need for forecasting approximately \(10\%\) beyond the end of the time series. To achieve this objective we perform a comprehensive analysis of the time series, starting by a preliminary presentation and exploration which revel that our data are not normally distributed and the volatility tends to change over time, this suggest to squared the returns to highlight volatility. We then proceed by plotting the sample ACF and PACF of both the returns and the squared returns. These plots reveal that the returns exhibit no significant linear autocorrelation, suggesting that they behave like a white noise process. However, the absence of linear correlation does not imply independence, and the squared returns display clear autocorrelation. Combined with the fact that the squared returns have a constant mean and variance, we conclude that they form a stationary process. This justifies modeling the squared returns using an ARMA (Autoregressive Moving Average) framework.

Subsequently, we select and estimate candidate ARMA models, relying on statistical justification, significance testing of coefficients, and automatic order selection criteria such as the Akaike Information Criterion (AIC). Considering the three stylized facts of financial time series volatility clustering, heavy tails, and absence of autocorrelation in the returns time series we identify a suitable GARCH model to capture the conditional heteroskedasticity in the return series.

Finally, we perform out-of-sample forecasting for approximately \(10\%\) beyond the end of the observed series. A plot of the forecast along with its prediction intervals is provided, and we explain how these intervals were constructed based on the conditional variance forecasted by the GARCH model.

Data Description and Exploration

Data Description

The company selected is dell, the data sets consist of the daily stock log returns of dell computer corporation from October 1993 to October 1998. . It is common to use log returns for analyze financial time series. During the exploratory analysis of the dataset, it was observed that the log returns exhibited a distribution reasonably close to normality. As a result, no data transformation is required at this stage, and the log returns will be used directly for the analysis. From this point forward, we will simply refer to the log returns as returns.

Data Exploration

The number of observation of our stock returns time series from October 1993 to October 1998 is 1261 observations, the plot of this is presented below displays evident volatility clustering, mean reversion, and occasional extreme movements. These characteristics suggest the returns are heteroscedastic and possibly non-normally distributed, which is typical of financial time series data. We can now think to squared the returns to highlight volatility, which helps visualize the magnitude of fluctuations without concern for direction. And the squared returns plot reveals clear volatility clustering, where large fluctuations group together in time. It also emphasizes the presence of extreme values, indicating that the return distribution has fat tails. This confirms the appropriateness of using ARCH/GARCH models to model and forecast volatility in this financial series. Some preliminary results for the return series are given in Table 1. The results reveals that the return series has a high kurtosis which suggests that the series is not normally distributed. This is confirmed by the tests for normality which are given in Table 2 and from a visual inspection of the histogram of the return shown in Figure 2.

# Compute moments for returns
moments_returns <- c(
  Mean     = mean(Rt),
  Min    = min(Rt),
  Max = max(Rt),
  Median = median(Rt),
  Variance = var(Rt),
  Skewness = skewness(Rt),
  Kurtosis = kurtosis(Rt)
)

# Compute moments for squared returns
moments_squared_returns <- c(
  Mean     = mean(Rt2),
  Min    = min(Rt2),
  Max = max(Rt2),
  Median = median(Rt2),
  Variance = var(Rt2),
  Skewness = skewness(Rt2),
  Kurtosis = kurtosis(Rt2)
)

# Combine into a table
moments_table <- tibble::tibble(
  Moment   = names(moments_returns),
  Returns = as.numeric(moments_returns),
  Squared_Returns = as.numeric(moments_squared_returns)
)


# Print the result
moments_table |> tbl(caption = "Statistical moments of returns and squared returns {#tbl-t1}")
Table 1: Statistical moments of returns and squared returns
Moment Returns Squared_Returns
Mean 0.366 11.45
Min -15.742 0.00
Max 18.849 355.30
Median 0.365 4.41
Variance 11.328 480.48
Skewness.V1 -0.053 6.63
Kurtosis.V1 4.723 74.26
# Kolmogorov-Smirnov test (against normal distribution with estimated mean and sd)
ks_r <- ks.test(Rt, "pnorm", mean = mean(Rt), sd = sd(Rt))
ks_sr <- ks.test(Rt2, "pnorm", mean = mean(Rt2), sd = sd(Rt2))

# Cramer-von Mises test
cvm_r <- cvm.test(Rt)
cvm_sr <- cvm.test(Rt2)

# Anderson-Darling test
ad_r <- ad.test(Rt)
ad_sr <- ad.test(Rt2)

# Combine results into a table
test_results <- data.frame(
  Test = c("Kolmogorov-Smirnov", "Cramér–von Mises", "Anderson-Darling"),
  Statistic_Returns = c(ks_r$statistic, cvm_r$statistic, ad_r$statistic),
  Pvalue_Returns     = c(ks_r$p.value, cvm_r$p.value, ad_r$p.value),
  Statistic_Squared  = c(ks_sr$statistic, cvm_sr$statistic, ad_sr$statistic),
  Pvalue_Squared     = c(ks_sr$p.value, cvm_sr$p.value, ad_sr$p.value)
)

# Print the table
test_results |> tbl(caption = "Normality tests on returns and squared returns {#tbl-t2}")
Table 2: Normality tests on returns and squared returns
Test Statistic_Returns Pvalue_Returns Statistic_Squared Pvalue_Squared
D Kolmogorov-Smirnov 0.028 0.288 0.301 0
W Cramér–von Mises 0.202 0.005 30.891 0
A Anderson-Darling 1.588 0.000 160.400 0
# plot of retuns

plot(Rt, ylab = "Returns")

hist(Rt, 
     breaks = 20, 
     probability = TRUE,  # This makes y-axis show density
     col = "lightblue", 
     main = "Histogram with Normal Curve",
     xlab = "Value")
curve(dnorm(x, mean = mean(Rt), sd = sd(Rt)), 
      col = "red", 
      lwd = 2, 
      add = TRUE)

plot(Rt2, ylab = "Squared Returns")

ACF and PACF of the returns series

The analysis of the returns through the ACF and PACF plots in Figure below, reveals that the series exhibits no significant autocorrelation, with most lags lying within the \(95\%\) confidence bands. This suggests that the returns behave like white noise, displaying no clear linear dependence or predictable structure. However, this lack of autocorrelation in the returns does not preclude the presence of volatility clustering, as previously observed in the squared returns plot. Therefore, while traditional ARMA models are not suitable for modeling the return series itself, the presence of time-varying volatility justifies the use of ARCH or GARCH models to capture the dynamics in the variance.

acf(Rt, main = "ACF of Returns")
pacf(Rt, main ="PACF of Returns")

We are going to recall in the next section some useful properties of GARCH model, which will guide us in the future steps of analysis.

GARCH processes Properties

GARCH (Generalized Autoregressive Conditional Heteroskedasticity) process is a process where the conditional mean is constant but the conditional variance is non-constant and hence an uncorrelated, but dependent process. The dependence of the conditional variance on the past causes the process to be dependent.

Let \(\{X_t\}_t\) be a GARCH(p,q) process, the dynamic is giving by the following equation:

\[X_t = \sigma_t Z_t\] \[\sigma_t^2 = \alpha_0 + \sum_{i= 1}^{p}\alpha_i X_{t-i} + \sum_{j=1}^{q}\beta_j \sigma_{t-j}^2\] where \(\{Z_t\}_t \sim \text{i.i.d. } \mathcal{N}(0, 1), \;\; \alpha_0 > 0, \;\; \alpha_i , \beta_j \geq 0.\)

\[X_t^2 = \alpha_0 + \sum_{i=1}^{m} (\alpha_i + \beta_i) X_{t-i}^2 - \sum_{j=1}^{q} \beta_j \eta_{t-j} + \eta_t\]

where the innovations \(\eta_t = X_t^2 - \sigma_t^2\) are mean-zero, uncorrelated.

Knowing this let’s now inspect the ACF and PACF of the squared returns.

Stationarity and P(ACF) of the squared returns

The visualization of the squared returns provides a reasonable assumption that the data is stationary. To investigate this further, a Dicky-Fuller test was conducted using R Studio, returning a p-value smaller than \(0.01\), so we reject the null hypothesis and accept stationarity. Therefore this suggest to model the squared returns with an ARMA(p,q) model. To determine the degrees of the ARMA model, the ACF and PACF were plotted, shown below.

Visual analysis

The plots show a strong autocorrelation at lag 1, and several subsequent lags also show small but significant autocorrelations, the PACF has significant spikes at multiple lags, especially early on, and they gradually decay. This suggests an ARMA(p,q) with p or q=1 and p or q=2.

# ACF and PACF of the squared returns

acf(Rt2, main = "ACF of squared Returns")
pacf(Rt2, main = "PACF of squared Returns")

AIC criterion of ARMA processes

Each of the proposed models was fit to the squared returns time series using R-Studio using the maximum likelihood method. The \(20\%\) best model results are shown in the table below.

Comp.Sarima(
  Rt2, d = 0, saison = NA, D = 0,
  p.max = 2, q.max = 2, P.max = 0, Q.max = 0
) |>
  kable(caption = "Comparison of ARMA models based on AIC")
modele (p,d,q)x(P,D,Q)_saison :  1 0 2 x 0 0 0 _ NA :  nb param:  3     AIC: 11309 
modele (p,d,q)x(P,D,Q)_saison :  2 0 2 x 0 0 0 _ NA :  nb param:  4     AIC: 11304 

Table: Comparison of ARMA models based on AIC

An ARMA(1, 2) model was chosen, because it had lowest number of parameter and the AIC value was not too far from the lowest AIC value. Knowing that the squared returns is an ARMA(1,2), base on the GARCH properties we can say that returns could be a GARCH(1,2) or GARCH(2,2). We will also test if a GARCH(1,1) would be sufficient to model the returns.

GARCH Model for Returns time series

GARCH model estimation

Conducting many GARCH models to fit out our returns series, base on the AIC criterion we concluded that GARCH(1,2) is the best as it had the lowest AIC value of \(5.223368\) (see in the appendix). Which is express as follow :

\[X_t = \sigma_t Z_t \;\;\;\{Z_t\}_t \sim \text{i.i.d. } \mathcal{N}(0, 1)\]

\[\sigma_t^2 = 0.77443 + 0.08694 X_{t-1}^2 + 0.63982 \sigma_{t-2}^2\]

Estimating the coefficients of our model, the results in the appendix. It is noticeable that \(\beta_1\) is not significant. This is why we drop \(\beta_1\) in the dynamical equation of the GARCH(1,2) model for the returns.

Analysis of residuals

The standard residuals was tested for significance using Ljung-Box Test. The squared of the standard residuals was also accounted for (see the table below).

fit1 <- garchFit(data ~ garch(1,2), data = Rt, trace = F, include.mean = F)


fit2 <- garchFit(data ~ garch(2,2), data = Rt, trace = F, include.mean = F)


fit3 <- garchFit(data ~ garch(1,1), data = Rt, trace = F, include.mean = F)
Standardized Residuals Tests
Test On Statistic p-Value
Jarque-Bera Test R \(\chi^2 = 30.1650866\) 2.816662e-07
Shapiro-Wilk Test R \(W = 0.9946136\) 1.685102e-04
Ljung-Box Test (10) R \(Q(10) = 8.6385637\) 5.667138e-01
Ljung-Box Test (15) R \(Q(15) = 10.5385505\) 7.966136e-01
Ljung-Box Test (20) R \(Q(20) = 11.3620376\) 9.362880e-01
Ljung-Box Test (10) \(R^2\) \(Q(10) = 4.6650212\) 9.124032e-01
Ljung-Box Test (15) \(R^2\) \(Q(15) = 13.3756625\) 5.733049e-01
Ljung-Box Test (20) \(R^2\) \(Q(20) = 20.8776102\) 6.404376e-01
LM Arch Test R \(TR^2 = 9.6805963\) 6.439589e-01

The results from the standardized residuals tests assess the adequacy of a returns time series model. The Jarque-Bera and Shapiro-Wilk tests both have very small p-values (\(2.82e^{-07}\) and \(1.69e^{-04}\), respectively), indicating that the residuals deviate significantly from normality. However, the Ljung-Box tests on residuals (R) and squared residuals (\(R^2\)) across various lags (10, 15, 20) yield high p-values, suggesting no significant autocorrelation or remaining ARCH effects in the residuals or their squares. The LM Arch Test also confirms this with a high p-value (0.644), indicating no significant conditional heteroscedasticity. Overall, while the residuals are not normally distributed, they do not show evidence of autocorrelation or ARCH effects, suggesting that the model captures the serial structure and volatility well.

Construction of Prediction Interval

Constructing a prediction interval involves estimating the range within which future observations of a time series (or model output) are likely to fall, with a certain level of confidence (e.g., \(95\%\)). This is different from a confidence interval, which estimates the range for the mean of the population or regression function.

In a GARCH model, the prediction interval for a future value \(X_{t+h}\) is constructed using the assumption of conditional normality, meaning that given past information \(\mathcal{F}_t\), the future value \(X_{t+h}\) is normally distributed with mean \(\hat{X}_{t+h}\) and variance \(\hat{\sigma}^2_{t+h}\). Although the GARCH process itself is not normally distributed unconditionally, this conditional normality allows us to build a prediction interval as

\[\hat{X}_{t+h} \pm z_{\alpha/2} \cdot \sqrt{\text{MSE}_h},\]

where \(\text{MSE}_h = \mathbb{E}_t[(X_{t+h} - \hat{X}_{t+h})^2] = \hat{\sigma}^2_{t+h}\) is the conditional forecast error variance at horizon h , and \(z_{\alpha/2}\) is the quantile of the standard normal distribution (e.g., 1.96 for 95% confidence).

Prediction of the conditional variance

The graphic bellow shows prediction intervals from a GARCH model with a constant conditional variance, meaning that the forecasted variance \(\hat{\sigma}^2_{t+h}\) does not change with the forecast horizon h. This results in prediction intervals \(\hat{X}_{t+h} \pm 1.96 \cdot \sqrt{\hat{\sigma}^2_{t+h}}\) that are of constant width, as observed in the plot. The flat shape of the intervals reflects the assumption that future volatility is expected to remain stable over time, which is characteristic of a GARCH model with low persistence (i.e., small values of \(\alpha + \beta_1 +\beta_2\)). Consequently, both the upper and lower confidence bounds remain parallel and equidistant from the forecasted mean.

# Prediction of the conditional variance

predict(fit1, n.ahead = (10/100)*length(Rt),plot=TRUE)

Conclusion

The aim of this work was to analyze and predict the volatility of a financial time series data. The time series of interest were the daily stock returns of dell computer corporation from October 1993 to October 1998. Modeling volatility in financial time series plays an important role in decision making, for example: what type of investment strategy to use. These strategies could be related to the choice of the timing of an investment, how long to hold a particular share and the size of an investment etc. This work focused on two methods, first ARMA to model the squared returns and second GARCH to model the returns. Subsequently, we select and estimate candidate ARMA models, relying on statistical justification, significance testing of coefficients, and automatic order selection criteria such as the Akaike Information Criterion (AIC). Considering the three stylized facts of financial time series volatility clustering, heavy tails, and absence of autocorrelation in returns we identify a suitable GARCH model to capture the conditional heteroskedasticity in the return series.

Finally, we perform out of sample forecasting for approximately \(10\%\) beyond the end of the observed series. A plot of the forecast along with its prediction intervals is provided, and we explain how these intervals were constructed based on the conditional variance forecasted by the GARCH(1,2) model.