0. Abstract

This project is mainly focusing on the assessing financial risk on APPLE Inc.(AAPL). Value at Risk(VaR) computed by different volatility prediction methods (GARCH(p,q) and EWMA) are discussed and compared, based on two cicumstances: general market condition and extreme market condition. In the parametric method to calculate VaR, Normal Distribution is adopted to capture the market risk under general market condition, whereas General Pareto Distribution is used to capture market risk when extreme events happen. Also, historical simulation is used to compute VaR in this report. In oreder to help investor understand the potential loss, Expexted Shortfall is provided in the report.

i. Introduction

APPLE Inc.(AAPL) is a famous U.S company which sells mobile devices and computers. In this report, the stock performance and risk analysis are conducted, the predicted exposure and the volatility forecasting are all covered in this report. It should be comprehensive enough to read the analysis for a client with little mathematic or statistic background. By reading this report, a potential investor should have enough information about risk exposure and potential loss if investing in AAPL.

Stock Performance Overview

The data of Apple Inc. stock is downloaded from Yahoo Finance. The stock performance from 2010 to 2019 is ploted as below.

The annual largest two losses from AAPL from 2010 to 2018 are plotted as the graph above. The black points are the largest losses whereas the grey points are the second largest losses in each year. The highest loss of AAPL occured around 2013, which is reasonable since the volatility is also the highest around 2013.

Instead of analyzing in stock price series, it is more appropriate to analyze and predict the stock performance via log return series.

ii. Statitstical Background

Stationary

The concept of stationary is that the distribution of interested variable will not change as time varies. Further prediction and analysis should stand on the basis of stationary time series.

## 
##  Augmented Dickey-Fuller Test
## 
## data:  AAPL$ret
## Dickey-Fuller = -12.904, Lag order = 13, p-value = 0.01
## alternative hypothesis: stationary

We can use Dickey-Fuller test to test for its stationarity. From the result above, since the p-value is smaller than 0.05, it is significant enought under 95% of confidence level. The result suggests that the return series of Apple Inc. is stationary.

Extreme Value Theory

Since many statistical models are focusing on the entire distribution of variable of interest, these models may choose to neglect the properties and characteristics of the observations located at tails. Those observations are considered as extreme events, but it did occur when the financial crisis on 2008. We will introduce Generalized Pareto Distribution, in order to capture the risk of these extreme events.

Generalized Extreme Value Distribution(GEV)

GEV distribution is composed of three kinds of different distributions: Gumbel(\(\xi=0\)),Frechet(\(\xi>0\)), and Negative Weibull(\(\xi<0\)).

\(GEV(\mu, \sigma, \xi)= exp{\{-[1+\xi (\frac{x- \mu}{\sigma})]^{-\frac{1}{\xi}}_{+}}\}\), where \(x_{+}= max(x,0)\)

r block maxima model

The two largest annual losses are drawn out from the AAPL data. GEV is fitted to the r block maxima data. The parameters ML estimated values are given as below.

##                         mu     sigma        xi
## 1       Estimate 5.8442257 1.6151504 0.1589672
## 2 Standard Error 0.4676648 0.3581171 0.1921814

The goodness of fit can be checked visually by the following plots. On the first column, the PP plot shows a satisfying fit. The QQ plot on the second column reflects some observations at tails can not be captured by GEV well. Look at the values of 1 year return period at the boundary of upper confidence band. The upward sloping return level curve indicates the Frechet type GEV.

Generalized Pareto Distribution(GPD)

\(G_{\xi, \beta (x)}\)(x)= \(\begin{cases} 1-(1+\xi \frac{x}{\beta})^{-\frac{1}{\xi}}, \xi \neq 0 \\ 1-exp(\frac{x} {\beta}), \xi=0 \end{cases}\)

To determine extreme events: Peaks-Over-Threshold approach

In the following analysis, we are only using Peaks-Over-Threshold approach(POT) to decide whether a certain observation is an extreme event. As its name states, the conept is for all observations that exceed a certain threshold value, then those observations are extreme events, mathematically presented as: \(P(X>u+y|X>u)=\frac{1-F(u+y)}{1-F(u)}, y>0\), u is a threshold. The exceedances(X-u) follow Generalized Pareto Distribution.

Volatility Prediction

In oreder to capture the risk of the stock, volatility prediction is a critical procedure in the analysis. In the following paragraph, two general volatility estimation methods are introduced.

a. GARCH(p,q)

GARCH stands for Generalized AutoRegressive Conditional Heteroskedasticity model. This volatility model incorporates past p historical returns and q volatility for the purpose of volatility forecasting. We will use Likelihood Ratio Test to decide the optimal choice of p and q. From the summary table provided below, the test suggests that GARCH(4,1) should be one of the best model among GARCH(1,1), GARCH(3,1), and GARCH(4,1).

##   Unrestricted Model Restricted Model  p-value
## 1         GARCH(4,1)       GARCH(1,1) 0.990318
## 2         GARCH(1,1)       GARCH(3,1)        1
## 3         GARCH(3,1)       GARCH(4,1)        1

Take p=4, q=1, GARCH(4,1): \(\sigma_{t}^{2}= \omega+ \alpha_{1} Y_{t-1}^{2}+ \alpha_{2} Y_{t-2}^{2}+ \alpha_{3} Y_{t-3}^{2} + \alpha_{4} Y_{t-4}^{2}+ \beta \sigma_{t-1}^{2} \approx 0.0890Y_{t-1}^{2}+0.0056Y_{t-3}^{2}+ 0.0008Y_{t-4}^{2}+ 0.8340 \sigma_{t-1}^{2}\),

where \(Y_{i}\) denotes the return at time i, and \(\sigma_{t}\) is the volatility of the stock at time t.

b. EWMA

EWMA stands for Exponentially Weighted Moving Average model. This is a variant version of GARCH(1,1). We follow the suggestion from the model proposer- J.P. Morgan to take \(\lambda=0.94\) while predicting volatility.

EWMA: \(\sigma_{t}^{2}= (1-\lambda)Y_{t-1}^{2}+ \lambda \sigma_{t-1}^{2}= 0.06Y_{t-1}^{2}+0.94\sigma_{t-1}^{2}\),

where \(Y_{t-1}\) denotes the return at time t-1, and \(\sigma_{t}\) is the volatility of the stock at time t.

iii. Statistical Analysis and Results

In this section, those statistical concepts mentioned previously will be adopted to quantifying the market risk of AAPL. Value at Risk under general condition and extreme condition, and expected shortfall are being discuessed in this section.

Value at Risk

The loss on a trading portfolio such that there is a probability p of losses equaling or exceeding Value at Risk(VaR) in a given trading period, i.e. \(Prob[Loss<-VaR(p)]=p\), where p is the confidence level. Parametric method and historical simulation method are adopted to compute VaR.

Parametric: normal model-based method

We assume the return of AAPL follows Normal distribution with mean=0, standard deviation= \(\sigma_{AAPL}\). It is possibly one of the most accurate method since it follows normal distribution(by Central Limit Theorem) in general condition. VaR can be calculated as follow:

\(VaR(0.95)= -Amt \times \sigma_{AAPL} \times Q_{0.05}\), where \(Q_{0.05}\) is the normal quantile of 0.05, and Amt is the amount invested in AAPL.

a. Normal Distribution with GARCH variance

Under GARCH(4,1) model, \(\sigma_{t}^{2}\approx 0.00009050749\)

\(\sigma_{t}= 0.009514\)

Under 95% of confidence level, for every 1000 dollars of investment, \(VaR(0.95)= -1000 \times 0.009514 \times (-1.65)=15.6981\)

b. Normal Distribution with EWMA variance

Under EWMA model, \(\sigma_{t}^{2}= 0.06 Y_{t-1}^{2}+ 0.94 \sigma_{t-1}^{2}= 0.0001248765\)

\(\sigma_{t}= 0.01117482 \approx 0.011175\)

Under 95% of confidence level, for every 1000 dollars of investment, \(VaR(0.95)= -1000 \times 0.011175 \times (-1.65)=18.4388\)

Parametric: GPD model-based method

As mentioned above, GPD is a method to capture the characteristics of extreme events. VaR can be inferred by Generalized Pareto Distribution and can be calculated as follow:

\(VaR(1-\alpha)= Amt \times q_{\alpha}(F)= Amt \times (u+\frac{\sigma}{\xi}((\frac{1-\alpha}{F(u)})^{-\xi}-1))\), where \(F_{u}\) is the number of non-exceedances relative to the sample size.

To apply POT method, a suitable threshold value can be obtained by Mean Residual Live Plot(MRL). In the graph provided below, 95% confidence bands around the mean excesses are colored in grey. Choose the threshold u to be 5 since the linear relationship is gone approximately at 5.

VaR under 95% of confidence level is computed to be: \(VaR(0.95)= q_{0.05} \times Amt=(2.706249 \times 0.01) \times 1000= 27.06249\)

Non-parametric: Historical Simulation

We order the log return from the smallest to the largest, and use the given significance level \(\alpha = 0.05\), find the \((\alpha \times\) number of log return\()th\) smallest log return, then\(VaR(0.95)= 25.3786\).

To summarize, for a thousand dollar of investment in AAPL, there will be only 5% of probability that you will lose for more than 18.4388 in general cases, and 27.06249 in extreme cases. If consider both cases altogether, statistically there will be 5 percent of probability that an investor will lose for more than 25.37865.(The result depends on the method of volatility estimation.)

Expected Shortfall

Expected shortfall(ES) is a conditional expected value below the quantile for a given peobability p. In other words, expected shortfall is the expected loss conditional on VaR being violated. \(ES=-E[Q|Q \le -VaR(p)]\) To be short, expected shortfall is the average of all VaR’s which are greater than the specified VaR(p). It serves a different character from VaR since ES is the calculation loss given that the loss has been located to the far left tail, whereas VaR does not imply the quantile of profit and loss.

We use parametric method to calculate VaR and the corresponding Expected Shortfall based on the following methods:

Normal model-based method with EWMA volitility

For simplicity, we take the volatility from EWMA approach and calculate VaR with normal model-based approach. The expected shortfall of 95% is 21.58212.

GPD model-based method

If we use GPD distribution instead, the expected shortfall of 95% should be 38.72467.

Historical Simulation

Followed the same logic as calculating VaR, The expected shortfall of 95% is calculated to be 37.4674.

To summarize, under 95% of confidence level, for a thousand dollar of investment in AAPL, the expected shortfall is 21.58212 in general cases, and 38.72467 in extreme cases. If consider both cases altogether, the expected shortfall turns out to be 37.4674.

iv. Conclusion

In this report, we investigate thoroughly on the popular Risk Measurements method, combing with extreme value theory. In most cases, the risk can be quantified by Value at Risk and Expected Shortfall, and calculated under three cirsumstances: general condition, extreme conditions, and altogother condition. Among three cases, the investors should be aware that 27.06249(maximum) of a 1000 AAPL are exposed under market risk. Once the VaR is breached, they might suffer from 37.4674(maximum) of capital loss for a thousand of investment in AAPL.

After reading this report, an investor who is interested in the stock of APPLE Inc. should be informed by sufficient risk information and potential losses.

v. Appendix

AAPL <- read.csv("./AAPL.csv", header= TRUE)
AAPL$Date <- as.Date(AAPL$Date)
suppressPackageStartupMessages(library(ggplot2))
ggplot(data= AAPL, aes(x= AAPL$Date,y=AAPL$Adj.Close, group=1))+ geom_line()+ labs(x= "Date(Month-Year)",y= "Price", title= "AAPL Adj.Close")+ scale_x_date(date_breaks = "1 years" , date_labels = "%m-%y")
ret <- diff(log(AAPL$Adj.Close))
AAPL$ret[2:nrow(AAPL)] <- ret[1:length(ret)]
AAPL$ret[1] <- 0
AAPL$Date <- as.Date(AAPL$Date)
library(ggplot2)
ggplot(data= AAPL, aes(x= AAPL$Date,y=AAPL$ret, group=1))+ geom_line()+ labs(x= "Date(Month-Year)",y= "Log Return", title= "AAPL return")+ scale_x_date(date_breaks = "1 years" , date_labels = "%m-%y")
suppressPackageStartupMessages(library(evir))
AAPL$loss <- -1*AAPL$ret*100
year <- format(AAPL$Date, "%Y")
loss <- AAPL$loss
attr(loss, "years") <- year
yearu <- unique(year)
idx <- 1:length(yearu)
r<-2
lossOrder <- t(sapply(idx, function(x){head(sort(loss[attr(loss,"year")==yearu[x]],decreasing = TRUE),r)}))
rownames(lossOrder)<- yearu
colnames(lossOrder)<- paste("r",1:r, sep=" ")
plot(yearu, lossOrder[,1],col="black",ylim=range(lossOrder),ylab="Losses from AAPL",xlab=" ", pch=21, bg="black", main= "Two largest annual losses from AAPL")
points(yearu, lossOrder[,2], col="grey",pch=23,bg="grey")
suppressPackageStartupMessages(library(tseries))
suppressWarnings(adf.test(AAPL$ret, alternative = "stationary"))
suppressPackageStartupMessages(library(evir))
suppressPackageStartupMessages(library(ismev))
AAPL$loss <- -1*AAPL$ret*100
year <- format(AAPL$Date, "%Y")
loss <- AAPL$loss
attr(loss, "years") <- year
yearu <- unique(year)
idx <- 1:length(yearu)
r<-2
lossOrder <- t(sapply(idx, function(x){head(sort(loss[attr(loss,"year")==yearu[x]],decreasing = TRUE),r)}))
rownames(lossOrder)<- yearu
colnames(lossOrder)<- paste("r",1:r, sep=" ")
#plot(yearu, lossOrder[,1],col="black",ylim=range(lossOrder),ylab="Losses from AAPL",xlab=" ", pch=21, bg="black", main= "Two largest annual losses from AAPL")
#points(yearu, lossOrder[,2], col="grey",pch=23,bg="grey")
lossOrderFit <- rlarg.fit(lossOrder)
#rlarg.diag(lossOrderFit)
###Estimation
g11=garchFit(~ garch(1,1), data = AAPL$ret,include.mean=FALSE)     # GARCH(1,1)
g31=garchFit(~ garch(3,1), data = AAPL$ret,include.mean=FALSE)     # GARCH(3,1)
g41=garchFit(~ garch(4,1), data = AAPL$ret,include.mean=FALSE)     # GARCH(4,1)
s = var(AAPL$ret[1:30])        
for (t in 2:length(AAPL$ret)){             
  s = 0.06 * AAPL$ret[t-1]^2  + 0.94 * s
}
print(s)
suppressPackageStartupMessages(library(fExtremes))
#AAPL$loss <- -1*AAPL$ret*100
mrlPlot(AAPL$loss, umin=-10, umax=10)
f <- gpdFit(AAPL$loss, u=5)
result <- gpdRiskMeasures(f, 0.95)
result$quantile
p= 0.05
value= 1000
y= AAPL$ret
y_sort = sort(y)                   
#hist(y_sort,50, main= "empirical density of AAPL", xlab= "return")
VaR.nonparam = -y_sort[p*length(y)]*value             
#print(VaR.nonparam)   
p= c(0.01,0.02,0.03,0.04,0.05)
VaR= -1000*qnorm(p)*0.011175
mean(VaR)
ys = sort(AAPL$ret)                             # empirical density of msft returns
#hist(ys,50, main="empirical density")
op = length(AAPL$ret)*0.05                               # ys[op] is p-quantile of the empirical density
VaR = -ys[op]*1000          
#print(VaR) # VaR(0.05)
ES = -mean(ys[1:op])*1000   # corresponding ES (expectation over the values =< VaR(0.05))
print(ES)
result <- gpdRiskMeasures(f, 0.95)
result$shortfall

vi. Reference

Pfaff, B., 2016. Financial Risk Modelling And Portfolio Optimization With R., N.J: John Wiley.

Danielsson, J., 2013. Financial Risk Forecasting. Hoboken, N.J.: Wiley.