Estimating Risk MeasuresEstimating Risk...
Transcript of Estimating Risk MeasuresEstimating Risk...
![Page 1: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/1.jpg)
Estimating Risk MeasuresEstimating Risk Measures
Amath 546/Econ 589Eric Zivot
Spring 2013Spring 2013Updated: April 23, 2013
© Eric Zivot 2008
![Page 2: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/2.jpg)
Daily Simple Returns on MSFT
© Eric Zivot 2008
![Page 3: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/3.jpg)
Daily Simple Returns on S&P 500
© Eric Zivot 2012
![Page 4: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/4.jpg)
Nonparametric Risk Measures
# combined data> MSFT.GSPC.ret = cbind(MSFT.ret,GSPC.ret)
# standard deviation> apply(MSFT.GSPC.ret, 2, sd)MSFT.Adjusted GSPC.Adjusted
0 02139 0 013740.02139 0.01374
# empirical 5% and 1% quantiles (historical VaR)> apply(MSFT.GSPC.ret, 2, quantile, probs=c(0.05, 0.01))
MSFT.Adjusted GSPC.Adjusted5% -0.03116 -0.021381% -0.06058 -0.03838
© Eric Zivot 2012
![Page 5: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/5.jpg)
Nonparametric Risk Measures
# function to compute historical 5% and 1% ESES.fun = function(x, alpha=0.05) {qhat = quantile(x, probs=alpha)mean(x[x <= qhat])
}
> apply(MSFT.GSPC.ret, 2, ES.fun, alpha=0.05)MSFT.Adjusted GSPC.Adjusted
-0.04970 -0.03256
> apply(MSFT.GSPC.ret, 2, ES.fun, alpha=0.01)MSFT.Adjusted GSPC.Adjusted
-0.08252 -0.054000.08252 0.05400
© Eric Zivot 2012
![Page 6: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/6.jpg)
PerformanceAnalytics Functions
> library(PerformanceAnalytics)> VaR(MSFT.GSPC.ret, p=0.95, method="historical")> VaR(MSFT.GSPC.ret, p 0.95, method historical )
MSFT.Adjusted GSPC.AdjustedVaR -0.03116 -0.02138
> ES(MSFT GSPC t 0 95 th d "hi t i l")> ES(MSFT.GSPC.ret, p=0.95, method="historical")MSFT.Adjusted GSPC.Adjusted
ES -0.0497 -0.03256
© Eric Zivot 2012
![Page 7: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/7.jpg)
Nonparametric 5% VaR and ES
© Eric Zivot 2012
![Page 8: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/8.jpg)
Normal VaR and ES# MLEs for mu and sigma> mu.hat = apply(MSFT.GSPC.ret, 2, mean)> sigma.hat = apply(MSFT.GSPC.ret, 2, sd)
# normal quantile and ES estimates> q.05.z = mu.hat + sigma.hat*qnorm(0.05)> q.01.z = mu.hat + sigma.hat*qnorm(0.01)
# mean return below quantile estimates> es.05.norm = -(mu.hat + sigma.hat*dnorm(qnorm(0.05))/0.05)> es 01 norm = -(mu hat + sigma hat*dnorm(qnorm(0 01))/0 01)> es.01.norm = -(mu.hat + sigma.hat*dnorm(qnorm(0.01))/0.01)
© Eric Zivot 2012
![Page 9: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/9.jpg)
Normal VaR and ES> mu.hatMSFT.Adjusted GSPC.Adjusted
1.161e-04 8.497e-05 > sigma.hat> sigma.hatMSFT.Adjusted GSPC.Adjusted
0.02139 0.01374 > q.05.normMSFT Adj t d GSPC Adj t dMSFT.Adjusted GSPC.Adjusted
-0.03507 -0.02252 > q.01.normMSFT.Adjusted GSPC.Adjustedj j
-0.04965 -0.03188 > es.05.normMSFT.Adjusted GSPC.Adjusted
0 04424 0 02843-0.04424 -0.02843 > es.01.normMSFT.Adjusted GSPC.Adjusted
-0.05713 -0.03671
© Eric Zivot 2012
![Page 10: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/10.jpg)
PerformanceAnalytics Functions
> VaR(MSFT.GSPC.ret, p=0.95, method="gaussian")MSFT.Adjusted GSPC.AdjustedMSFT.Adjusted GSPC.Adjusted
VaR -0.03506 -0.02251
> ES(MSFT.GSPC.ret, p=0.95, method="gaussian")MSFT Adj t d GSPC Adj t dMSFT.Adjusted GSPC.Adjusted
ES -0.044 -0.02826
© Eric Zivot 2012
![Page 11: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/11.jpg)
© Eric Zivot 2012
![Page 12: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/12.jpg)
MLE of Student’s t Distribution
# Fit Student's t distribution by MLE using fitdistr from# MASS pacakge# Assume MSFT.ret is student's t with parameters mu, sigma# Assume MSFT.ret is student s t with parameters mu, sigma# and v# note: E[MSFT.ret] = mu, # var(MSFT.ret) = sigma^2 * (v/(v-2)) # l t b 100 t i i l t bilit f MLE# scale returns by 100 to improve numerical stability of MLE> library(MASS)> MSFT.t.mle = fitdistr(MSFT.ret*100, densfun="t")> MSFT.t.mle
m s df-0.006685 1.250321 2.659188
( 0.027828) ( 0.032016) ( 0.157775)
# extract and rescale estimates> theta.hat = coef(MSFT.t.mle)> mu.MSFT.t = theta.hat["m"]/100
© Eric Zivot 2012
> sigma.MSFT.t = theta.hat["s"]/100> v.MSFT.t = theta.hat["df"]
![Page 13: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/13.jpg)
Student’s t VaR for MSFT
# Standard t quantiles> q.t.05 = qt(0.05, df=v.MSFT.t)> q.t.05 qt(0.05, df v.MSFT.t)> q.t.01 = qt(0.01, df=v.MSFT.t)
# Estimated t Quantiles for MSFT> MSFT t 05 MSFT t + i MSFT t* t 05> q.MSFT.t.05 = mu.MSFT.t + sigma.MSFT.t*q.t.05> q.MSFT.t.01 = mu.MSFT.t + sigma.MSFT.t*q.t.01
> q.MSFT.t.05qm
-0.03109
> q MSFT t 01> q.MSFT.t.01m
-0.06309
© Eric Zivot 2012
![Page 14: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/14.jpg)
Student’s t ES for MSFT
# Student-t multipliers for ES> t.adj.05 = (dt(q.t.05, df=v.MSFT.t)/0.05)*((v.MSFT.t + + q.t.05^2)/(v.MSFT.t - 1))+ q.t.05 2)/(v.MSFT.t 1))> t.adj.01 = (dt(q.t.01, df=v.MSFT.t)/0.01)*((v.MSFT.t + + q.t.01^2)/(v.MSFT.t - 1))# Student t ES estimates> MSFT t 05 ( MSFT t + i MSFT t*t dj 05)> es.MSFT.t.05 = -(mu.MSFT.t + sigma.MSFT.t*t.adj.05)> es.MSFT.t.01 = -(mu.MSFT.t + sigma.MSFT.t*t.adj.01)
> es.MSFT.t.05m
-0.05388
> es MSFT t 01> es.MSFT.t.01m
-0.1032
© Eric Zivot 2012
![Page 15: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/15.jpg)
Simulating Student’s t VaR and ES # simulate data from fitted Student's t distribution# t.v ~ standardized Student t with v df. E[t.v] = 0, # var(t.v) = v/(v-2)> set.seed(123)> set.seed(123)> t.sim = mu.MSFT.t + sigma.MSFT.t*rt(n=10000, + df=v.MSFT.t)> q.t.sim = quantile(t.sim, probs=c(0.05, 0.01))
0 ( 1 )> es.t.05 = mean(t.sim[t.sim <= q.t.sim[1]])> es.t.01 = mean(t.sim[t.sim <= q.t.sim[2]])
# simulated quantiles# q> q.t.sim
5% 1% -0.03253 -0.06643
# simulated ES> es.t.05[1] -0.05563
© Eric Zivot 2012
> es.t.01[1] -0.1025
![Page 16: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/16.jpg)
Modified VaR and ES
# Use PerformanceAnalytics Functions VaR and ES
# Modified VaR#> modifiedVaR.05 = VaR(MSFT.GSPC.ret, p=0.95, + method="modified")> modifiedVaR.01 = VaR(MSFT.GSPC.ret, p=0.99, + method "modified")+ method="modified")
# Modified ES> modifiedES.05 = ES(MSFT.GSPC.ret, p=0.95, + method="modified")> modifiedES.01 = ES(MSFT.GSPC.ret, p=0.99, + method="modified")
© Eric Zivot 2012
![Page 17: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/17.jpg)
Modified VaR and ES
> modifiedVaR.05> modifiedVaR.05MSFT.Adjusted GSPC.Adjusted
VaR -0.02962 -0.02036> modifiedVaR.01
MSFT Adj t d GSPC Adj t d
Note: results are strange – VaR and
MSFT.Adjusted GSPC.AdjustedVaR -0.09036 -0.05513
> modifiedES.05
gES estimates are the same !!!
MSFT.Adjusted GSPC.AdjustedES -0.02962 -0.02974> modifiedES.01
MSFT Adjusted GSPC AdjustedMSFT.Adjusted GSPC.AdjustedES -0.09036 -0.05513
© Eric Zivot 2012
![Page 18: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/18.jpg)
Estimating Portfolio Risk Measures
# equally weighted portfolio of MSFT and GSPC> port.ret = 0.5*MSFT.ret + 0.5*GSPC.ret> colnames(port.ret) = "port"(p ) p
> mean(port.ret)[1] 0.0001005
> sd(port.ret)port
0.01615 Warning message:sd(<matrix>) is deprecated.Use apply(*, 2, sd) instead.
> sd(as.numeric(port.ret))[1] 0.01615
© Eric Zivot 2012
![Page 19: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/19.jpg)
Estimating Portfolio Risk Measures
# Estimating portfolio vol using covariance matrix and # weights> Sigma.hat = cov(MSFT.GSPC.ret)> w = c(0.5, 0.5)> sqrt(t(w)%*%Sigma.hat%*%w)
[ 1][,1][1,] 0.01615
© Eric Zivot 2012
![Page 20: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/20.jpg)
Estimating Volatility Risk Budgets# estimating contributions to Vol> sigma.p.hat = as.numeric(sqrt(t(w)%*%Sigma.hat%*%w))> mcr.vol = Sigma.hat %*% w / sigma.p.hat> cr.vol = w * mcr.vol> cr.vol w mcr.vol> pcr.vol = cr.vol / sigma.p.hat> cbind(mcr.vol, cr.vol, pcr.vol)
[,1] [,2] [,3]MSFT Adj t d 0 02031 0 010154 0 6289MSFT.Adjusted 0.02031 0.010154 0.6289GSPC.Adjusted 0.01199 0.005993 0.3711
# check> sigma.p.hat[1] 0.01615> sum(cr.vol)[1] 0 01615[1] 0.01615> sum(pcr.vol)[1] 1
© Eric Zivot 2012
![Page 21: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/21.jpg)
Estimating Volatility Risk Budgets
# Use PerformanceAnalytics function StdDev()> StdDev(MSFT.GSPC.ret, portfolio_method="component",
i ht (0 5 0 5))+ weights=c(0.5, 0.5))$StdDev
[,1][1,] 0.01615[ ,]
$contribution[1] 0.010154 0.005993
$pct_contrib_StdDev[1] 0.6289 0.3711
© Eric Zivot 2012
![Page 22: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/22.jpg)
Empirical Bivariate Distribution
© Eric Zivot 2012
![Page 23: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/23.jpg)
Empirical Portfolio Return Distribution
> chart Histogram(port ret main="Equally Weighted Portfolio"
© Eric Zivot 2012
> chart.Histogram(port.ret, main= Equally Weighted Portfolio , + methods=c("add.normal“,”add.qqplot”)
![Page 24: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/24.jpg)
Nonparametric Estimation of Portfolio VaR and ES
# VaR> VaR(port.ret, p=0.95, method="historical")
portVaR -0.02514> VaR(port.ret, p=0.99, method="historical")
portpVaR -0.04445
# ES> ES( t t 0 95 th d "hi t i l")> ES(port.ret, p=0.95, method="historical")
portES -0.03761> ES(port.ret, p=0.99, method="historical")
portES -0.06024
© Eric Zivot 2012
![Page 25: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/25.jpg)
Bivariate Normal Distribution
> mu.hat = apply(MSFT.GSPC.ret, 2, mean)> Sigma.hat = cov(MSFT.GSPC.ret)> Cor.hat = cov2cor(Sigma.hat)> Cor.hat cov2cor(Sigma.hat)
> mu.hatMSFT.Adjusted GSPC.Adjusted
1 161 04 8 497 051.161e-04 8.497e-05
> Sigma.hatMSFT.Adjusted GSPC.Adjustedj j
MSFT.Adjusted 0.0004576 0.0001982GSPC.Adjusted 0.0001982 0.0001888
> Cor hat> Cor.hatMSFT.Adjusted GSPC.Adjusted
MSFT.Adjusted 1.0000 0.6743GSPC.Adjusted 0.6743 1.0000
© Eric Zivot 2012
![Page 26: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/26.jpg)
Simulated Bivariate Normal Returns
> set.seed(123)> sim.ret = rmvnorm(n.obs, mean=mu.hat, + sigma=Sigma.hat, method="chol")
© Eric Zivot 2012
![Page 27: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/27.jpg)
Simulated Normal Portfolio Returns
© Eric Zivot 2012
> port.ret.sim = 0.5*sim.ret[,1] + 0.5*sim.ret[,2]
![Page 28: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/28.jpg)
Estimated Portfolio Risk Measures # l tilit# volatility> StdDev(port.ret)
[,1]StdDev 0.01615
# VaR> VaR(port.ret, p = 0.95, method="gaussian")
portportVaR -0.02645> VaR(port.ret, p = 0.99, method="gaussian")
portVaR -0.03746
# ES> ES(port ret, p = 0 95, method="gaussian")> ES(port.ret, p 0.95, method gaussian )
portES -0.0332> ES(port.ret, p = 0.99, method="gaussian")
© Eric Zivot 2012
portES -0.04293
![Page 29: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/29.jpg)
Bivariate Student’s t Distribution> library(MASS) # needed for cov.trob> library(mnormt) # needed for dmt> df = seq(2.1,5,.01) # grid of v values> n = length(df)> n length(df)> loglik_max = rep(0,n)> for(i in 1:n)+ {
( ( ) )
MLE of mu and cov given df
+ fit = cov.trob(coredata(MSFT.GSPC.ret), nu=df[i])+ loglik_max[i] = sum(log(dmt(coredata(MSFT.GSPC.ret),+ mean=fit$center,+ S=fit$cov,df=df[i])))MLE of df given $ , [ ])))+ }
# find the maximum of the profile log-likelihood > lik (l lik )
MLE of df given mu and cov
> max.lik = max(loglik_max)
# find the value of v which maximizes the log-likelihood> v.mle = df[which(loglik_max == max.lik)]
© Eric Zivot 2012
_
![Page 30: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/30.jpg)
MLE of v in Bivariate Student’s t
ˆ 2.61mle
© Eric Zivot 2012
![Page 31: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/31.jpg)
MLE of Bivariate Student t# extract mle of mu and sigma given v.mle> fit.mle = cov.trob(coredata(MSFT.GSPC.ret),nu=v.mle)> mu.mle.t = fit.mle$center> Sigma mle t fit mle$co> Sigma.mle.t = fit.mle$cov> Cor.mle.t = cov2cor(Sigma.mle.t)
> mu.mle.tMSFT.Adjusted GSPC.Adjusted
3.653e-05 3.364e-04
> Sigma mle t*(v mle/(v mle - 2))> Sigma.mle.t*(v.mle/(v.mle - 2))MSFT.Adjusted GSPC.Adjusted
MSFT.Adjusted 0.0006388 0.0002998GSPC.Adjusted 0.0002998 0.0002977
> Cor.mle.tMSFT.Adjusted GSPC.Adjusted
MSFT.Adjusted 1.0000 0.6876
© Eric Zivot 2012
MSFT.Adjusted 1.0000 0.6876GSPC.Adjusted 0.6876 1.0000
![Page 32: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/32.jpg)
Simulate Returns from Multivariate t
# initialize random number generator(123)> set.seed(123)
# Generate N(0, Sigma) random variables> Z = rmvnorm(n=n.obs, mean=c(0,0), ( , ( , ),+ sigma=Sigma.mle.t*(v.mle/(v.mle - 2)))
# generate W ~ chi-sq(v.mle)> W hi ( b df l )> W = rchisq(n.obs,df=v.mle)
# simulate bivariate t> sim.ret.t = mu.mle.t + sqrt(v.mle/W)*Z> colnames(sim.ret.t) = c("MSFT","GSPC")
© Eric Zivot 2012
![Page 33: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/33.jpg)
Simulate Bivariate t Returns
© Eric Zivot 2012
![Page 34: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/34.jpg)
Simulated Portfolio Returns> port.ret.sim.t = 0.5*sim.ret.t[,"MSFT"] + 0.5*sim.ret.t[,"GSPC"]p [, ] [, ]
© Eric Zivot 2012
![Page 35: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/35.jpg)
Risk Measures from Simulated Returns# VaR> VaR(port.ret.sim.t, p = 0.95, method="historical")
[,1]0 02283VaR -0.02283
> VaR(port.ret.sim.t, p = 0.99, method="historical")[,1]
VaR -0.04494
# ES> ES(port.ret.sim.t, p = 0.95, method="historical")
[ 1][,1]ES -0.03699> ES(port.ret.sim.t, p = 0.99, method="historical")
[,1]ES -0.06371
© Eric Zivot 2012
![Page 36: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/36.jpg)
Risk Budgets from Simulated Returns
# Asset contributions to ES# Asset contributions to ES> ES(sim.ret.t, p=0.95, weights=c(0.5, 0.5), + portfolio_method="component", method="historical")$`-r_exceed/c_exceed`[1] 0 03709[1] 0.03709
$c_exceed[1] 154
Portfolio ES
# of returns less than VaR quantile[ ]
$realizedcontribMSFT GSPC
0 6207 0 3793Percent contribution to ES
0.6207 0.3793
© Eric Zivot 2012
![Page 37: Estimating Risk MeasuresEstimating Risk Measuresfaculty.washington.edu/ezivot/econ589/riskMeasuresPowerpoint.pdfNormal VaR and ES > mu.hat MSFT.Adjusted GSPC.Adjusted 1.161e-04 8.497e-05](https://reader035.fdocuments.in/reader035/viewer/2022071216/60475054b3ff3979970a7fb6/html5/thumbnails/37.jpg)
.05 .05[ | ]pRMSFTMSFT pMCES E R R q
© Eric Zivot 2012