1. Suppose \(X\) and \(W\) are independent random variables, and \(X\) is exponential with standard deviation of 2 and \(W\) is discrete random variable with \(P(W=2)=P(W=-2)=\frac{1}{2}\)
(a) \(\textbf{Solution.}\qquad\) Recall that the standard deviation of exponential distribution is of the form, \[ SD(X)=\frac{1}{\lambda}=2 \] this implies that \(\lambda=2\). Therefore, \(X\sim\mathrm{Exp}\left(\lambda=\frac{1}{2}\right)\) and its corresponding cdf is , \[ F(x)=1-e^{-x/2} \] The distribution of \(V\) can be written as,
\[\begin{align} \mathbb{P}(V\leq v) & =\mathbb{P}\left(\frac{1}{1+X}\leq v\right)\nonumber \\ & =\mathbb{P}\left(\frac{1}{v}-1\leq X\right)\nonumber \\ & =1-\mathbb{P}\left(X\leq\frac{1}{v}-1\right)\nonumber \\ & =\exp\left\{ -\frac{1}{2}\left(\frac{1}{v}-1\right)\right\} \label{eq:1} \end{align}\]
where \(v\in\left[0,1\right]\). We can solve for 0.1-quantile of \(V\) by solving for \(v\) in equation (\ref{eq:1}).
\[\begin{align*} \exp\left\{ -\frac{1}{2}\left(\frac{1}{v}-1\right)\right\} & =0.1\\ -\frac{1}{2}\left(\frac{1}{v}-1\right) & =\mathrm{log}(0.1)\\ \frac{1}{v} & =-2\log(0.1)+1\\ v & =\frac{1}{1-2\log(0.1)} \end{align*}\] Thus, 0.1-quantile of \(V\) is, \[ v_{0.1}\approx0.178 \]
(b) \(\mathbf{Solution.}\qquad\) We can compute distribution of \(Y\) as follows,
\[\begin{align} \mathbb{P}(Y\leq y) & =\mathbb{P}(WX\leq y)\nonumber \\ & =\mathbb{P}(WX\leq y\mid W=2)\mathbb{P}(W=2)+\mathbb{P}(WX\leq y\mid W=-2)\|P(W=-2)\nonumber \\ & =\frac{1}{2}\mathbb{P}(2X\leq y)+\frac{1}{2}\mathbb{P}(-2X\leq y)\nonumber \\ & =\frac{1}{2}\mathbb{P}\left(X\leq\frac{y}{2}\right)+\frac{1}{2}\mathbb{P}\left(X\geq-\frac{y}{2}\right)\label{eq:2} \end{align}\]
Then the equation (\ref{eq:2}) can be written as,
\[ \mathbb{P}\left(Y\leq y\right)=\left\{ \begin{array}{ll} {1-\frac{1}{2}\exp\left\{ -\frac{1}{4}|y|\right\} } & {\text{ if }y>0}\\ {\frac{1}{2}\exp\left\{ -\frac{1}{4}|y|\right\} } & {\text{ if }y\leq0} \end{array}\right. \]
which distribution is double exponential distribution with parameters \(\mu=0\) and \(\lambda=\frac{1}{4}\).
(c) \(\mathbf{Solution.}\qquad\) To find the 0.2-quantile of \(Y\), we first compute the distribution of \(Z\),
\[\begin{align} \mathbb{P}\left(Z\leq z\right) & =\mathbb{P}\left(\frac{1}{1+Y}\leq z\right)\nonumber \\ & =\mathbb{P}\left(\frac{1}{z}\leq1+Y\right)\nonumber \\ & =\mathbb{P}\left(\frac{1}{z}-1\leq Y\right)\nonumber \\ & =1-\mathbb{P}\left(Y\leq\frac{1}{z}-1\right)\nonumber \\ & =\frac{1}{2}\exp\left\{ -\frac{1}{4}\left(\frac{1}{z}-1\right)\right\} \label{eq:3} \end{align}\]
where \(0\leq z\leq1\). Then setting equation (\ref{eq:3}) equal to 0.2, we have
\[\begin{align*} \log(0.4) & =-\frac{1}{4}\left(\frac{1}{z}-1\right)\\ -4\log(0.4)+1 & =\frac{1}{z}\\ z & =\frac{1}{1-4\log(0.4)}\\ z & \approx0.214 \end{align*}\]
2. Suppose have portfolio of 100 million dollars. Compute the relative value-at-risk, valueat-risk, and expected shortfall for \(\alpha=.004\) for the following cases.
Clarification/Hints: For \((\mathrm{c}),\) you will need to set the scale parameter, \(\lambda,\) appropriately to get standard deviations being \(.025,\) and you will need to relate quantiles from the R-function “qt” which is for standard t-distribution with quantile of \(t_{\nu}(\mu, \lambda)\) for the appropriate \(\mu\) and \(\lambda\)
(a) \(\mathbf{Solution.}\qquad\) We are given \(R_{t}\sim N\left(0,\left(.02\right)^{2}\right)\). To find 0.004 quantile, we use qnorm R function,
## [1] -0.0530414
Then we know the value of relative VaR is,
\[ \tilde{\mathrm{VaR}}=0.053 \]
and the value at risk is,
\[ \mathrm{VaR}=100(0.053)=5.3\text{ million} \]
Next we compute \(ES_{0.004}\),
\[ ES_{0.04}=\frac{1}{0.004}\int_{0.053}^{\infty}xf(x)dx \]
where \(f(x)\sim N\left(0,(0.02)^{2}\right)\).
\[\begin{align} = & \frac{1}{0.004}\left(\frac{1}{\sqrt{2\pi}(0.02)}\right)\int_{0.053}^{\infty}xe^{\frac{-x^{2}}{2(0.02)^{2}}}dx\label{eq:4} \end{align}\]
We perform the change of variable,
\[\begin{align*} u & =\frac{x^{2}}{2(0.02)^{2}}\\ du & =\frac{1}{(0.02)^{2}}xdx \end{align*}\]
Then equation (\ref{eq:4}) becomes,
\[\begin{align*} = & \frac{1}{0.004}\left(\frac{0.02}{\sqrt{2\pi}}\right)\int_{3.517}^{\infty}e^{-u}du\\ = & \frac{-1}{0.004}\left(\frac{0.02}{\sqrt{2\pi}}\right)\left[\left.e^{-u}\right|_{3.517}^{\infty}=-e^{-3.517}\right]\\ = & \frac{5}{\sqrt{2\pi}}e^{-3.517}\\ \approx & 0.0592 \end{align*}\]
Thus, the shortfall is, \[ 100(0.0592)=5.92\text{ million} \]
(b) \(\mathbf{Solution.}\qquad\) We are given that the log-returns are distributed, \(\tilde{R}_{t}\sim N\left(0,\left(.02\right)^{2}\right)\). In order to find 0.004 quantile, we use the VaR from part a) and apply the following transformation,
\[ e^{\widetilde{R}_{t}}-1=R_{t} \]
Thus 0.004 quantile for \(R_{t}\) is, \[ e^{-0.053}-1=-0.0516 \]
So the relative value at risk is,
\[ \tilde{\mathrm{VaR}}=0.0516 \]
and the value at risk is,
\[ \mathrm{VaR}=100(0.0516)=5.16\text{ million} \]
Next we compute \({ES}_{0.04}\) from the following R code using Monte Carlo simulation.
n = 1e7
returns = exp(rnorm(n, mean = 0, sd = 0.02)) - 1
r_VaR = -0.0516
ind = which(returns <= r_VaR)
ES = -mean(returns[ind])
ES
## [1] 0.0574643
From the R code above, \[ ES_{0.004}\approx0.0575 \] And the shortfall is, \[ 100(0.0575)=5.75\text{ million} \]
(c) \(\mathbf{Solution.}\qquad\) In order to compute relative value-at-risk, value- at-risk, and expected shortfall, we will use the following custom R functions. We will also use these functions in questions 3c) and 3d).
qt_scale = function(p, mu, lambda, nu) {
# Returns quantile of scaled t-distribution
# Args:
# p: p-th quantile
# mu: mean
# lambda: scale parameter
# nu: degrees of freedom
return(mu + lambda * qt(p, df = nu))
}
rt_scale = function(n, mu, lambda, nu) {
# Returns random samples from scaled t-distribution
# Args:
# n: number of samples
# mu: mean
# lambda: scale parameter
# nu: degrees of freedom
return(mu + lambda * rt(n, df = nu))
}
compute_ES = function(returns, VaR) {
# Returns the expected shortfall from a vector of returns and VaR
ind = which(returns <= -VaR)
ES = -mean(returns[ind])
return(ES)
}
First we can compute value-at-risk and relative value at-risk using the following R code to get the quantiles.
# Compute Relative VaR and VaR
nu_vals = c(11, 6, 3)
capital = 100
lambda = 0.02 / sqrt(nu_vals / (nu_vals - 2))
r_VaR = -1 * qt_scale(alpha, 0, lambda, nu_vals)
VaR = round(capital * r_VaR, 2)
\(\nu = 11\) | \(\nu = 6\) | \(\nu = 3\) | |
---|---|---|---|
Relative VaR | 0.058 | 0.064 | 0.073 |
VaR (mm) | 5.850 | 6.370 | 7.300 |
Next, the following R code computes the expected shortfall by Monte Carlo simulation.
# Sample Returns
n = 1e7
returns = mapply(rt_scale, n, 0, lambda, nu_vals)
# Compute ES
ES = c()
for (i in 1:ncol(returns)) {
ES[i] = compute_ES(returns[, i], r_VaR[i])
}
shortfall = capital * ES
df = t(data.frame("ES" = ES, "Shortfall (mm)" = shortfall))
colnames(df) = c("nu = 11", "nu = 6", "nu = 3")
rownames(df) = c("ES", "Shortfall (mm)")
\(\nu = 11\) | \(\nu = 6\) | \(\nu = 3\) | |
---|---|---|---|
ES | 0.069 | 0.080 | 0.111 |
Shortfall (mm) | 6.898 | 7.971 | 11.147 |
3. In Canvas in the Data subdirectory under files is the data set of the daily price data of the Russell 2000 from Jan \(/ 2018\) to Dec \(/ 2019\).
(a) \(\mathbf{Solution.}\qquad\) Below in the following R code we extract adjusted close price price data and compute log returns to plot.
data = read.csv("Russ2000_Jan1_2018-Dec31_2019.csv")
data$Date = as.character(data$Date)
data$Month = as.Date(data$Date, "%m/%d/%Y")
adj_close = data$Adj.Close
log_ret = diff(log(adj_close))
data["Log_Ret"] = c(NA, log_ret)
# Build subplot of Adjusted Close and Log_Returns
p1 = ggplot(data, aes(x = Month, y = Adj.Close, group = 1)) +
geom_line() +
scale_x_date(labels = date_format("%m-%Y")) +
ggtitle("Adjusted Close Prices Russell 2000") +
theme(plot.title = element_text(hjust = 0.5))
p2 = ggplot(data, aes(x = Month, y = Log_Ret, group = 1)) +
geom_line() +
scale_x_date(labels = date_format("%m-%Y")) +
ggtitle("Log Returns Russell 2000") +
theme(plot.title = element_text(hjust = 0.5))
grid.arrange(p1, p2, nrow = 2)
The adjusted close price plot shows that that Russell 2000 reached its peak around September 2018 and steadily declined until the end of 2018. Since the beginning of 2019, the price rebounded. The log-return plot looks like a (weakly) stationary time series. From this plot we can also see that the largest return occurred at the end of December 2018.
(b) \(\mathbf{Solution.}\qquad\) Below we build a summary table of the log-returns.
# Compute Summary Statistics
summ = summary(log_ret)
mu_hat = mean(log_ret)
skew = skewness(log_ret)
kur = kurtosis(log_ret) # Original Kurtosis, not excess
sigma_hat = sd(log_ret)
# Build Summary Table
df1 = data.frame("Statistics" = unclass(summ), check.names = FALSE,
stringsAsFactors = FALSE)
df2 = data.frame("Statistics" = c(sigma_hat, skew, kur))
rownames(df2) = c("Std. Dev.", "Skewness", "Kurtosis")
df = rbind(df1, df2)
# Show Table
kable(df, digits = 3, format.args = list(big.mark = ","),
caption = "Summary Statistics of Log-Returns") %>%
kable_styling(latex_options = c("striped", "hold_position"))
Statistics | |
---|---|
Min. | -0.045 |
1st Qu. | -0.005 |
Median | 0.001 |
Mean | 0.000 |
3rd Qu. | 0.007 |
Max. | 0.048 |
Std. Dev. | 0.011 |
Skewness | -0.432 |
Kurtosis | 5.097 |
Next we show the histogram and box plot of log(adjusted closing price return),
# Compute Summary Statistics
# Build histogram and box plot of Log_Returns
p1 = ggplot(data, aes(x = Log_Ret, group = 1)) +
geom_histogram(aes(y = stat(count) / sum(count))) +
ggtitle("Histogram of Russell 2000 Log Returns") +
theme(plot.title = element_text(hjust = 0.5)) +
ylab("frequency")
p2 = ggplot(data, aes(y = Log_Ret, group = 1)) +
geom_boxplot(outlier.colour="red", outlier.shape=8,
outlier.size=4) +
ggtitle("Boxplot of Russell 2000 Log Returns") +
theme(plot.title = element_text(hjust = 0.5),
axis.ticks.y =element_blank(), axis.text.y =element_blank()) +
coord_flip() +
ylab("")
grid.arrange(p1, p2, nrow = 2)
First we note from the summary table that the median of log returns is close to its mean, indicating that we have a symmetric. The skewness is -0.432 which also indicates the distribution is symmetric, potentially with a slight left skew. Finally we note that the excess kurtosis is 2.097 which indicates that the distribution of log returns is heavy tailed.
(c) \(\mathbf{Solution.}\qquad\) Below we estimate relative VaR from t-distribution and also compute VaR from the log-returns.
nu = round(6 / (kur - 3) + 4)
lambda = sigma_hat / sqrt(nu / (nu - 2))
alpha = 0.005
# Estimated VaR from t-distribution
quantile_hat = qt_scale(alpha, mu_hat, lambda, nu)
r_VaR_hat = -1 * (exp(quantile_hat) - 1)
# Estimated VaR from log-returns
ret_quantile = quantile(log_ret, alpha)
r_VaR = -1 * (exp(ret_quantile) - 1)
df = t(data.frame("Relative VaR t-dist." = r_VaR_hat,
"Relative VaR" = r_VaR))
rownames(df) = c("Relative VaR t-dist.", "Relative VaR")
# Show Table
kable(df, digits = 3, format.args = list(big.mark = ","),
caption = "Comparison of Relative VaRs of Log-Returns") %>%
kable_styling(latex_options = c("striped", "hold_position"))
0.5% | |
---|---|
Relative VaR t-dist. | 0.031 |
Relative VaR | 0.036 |
Indeed the estimated relative VaR is close to the relative VaR of the log-returns.
(d) \(\mathbf{Solution.}\qquad\) Below we derive an estimate of the expected shortfall using Monte Carlo simulation.
# Compute ES
n = 1e7
capital = 10
returns = exp(rt_scale(n, mu_hat, lambda, nu)) - 1
ind = which(returns <= -r_VaR_hat)
ES = -mean(returns[ind])
shortfall = ES * capital
df = t(data.frame("ES" = ES, "Shortfall (mm)" = shortfall))
colnames(df) = c("0.5%")
rownames(df) = c("ES", "Shortfall (mm)")
# Show Table
kable(df, digits = 3, format.args = list(big.mark = ","),
caption = "Expected Shortfall of t-distribution Model") %>%
kable_styling(latex_options = c("striped", "hold_position"))
0.5% | |
---|---|
ES | 0.038 |
Shortfall (mm) | 0.384 |