[R-SIG-Finance] student t mixture VaR in R // imitate example 2.23 in C.Alexander: Market Risk IV
Alexios Ghalanos
alexios at 4dscape.com
Fri Apr 25 11:46:30 CEST 2014
A quick look at your code suggests that you should use "std" (student) not "sstd" (skew student) for distribution.
Alexios
> On 25 Apr 2014, at 09:49, Johannes Moser <jzmoser at gmail.com> wrote:
>
> Dear R community,
>
> in trying to set up a little simulation study I adapt the ideas found in
> "Carol Alexander: Market Risk IV - Value at Risk Models" on page 111 ff.
> and implement them in R.
> This project is about student t mixture distributions and Value at Risk
> / Expected Shortfall.
>
> The following code is my setup so far, and the syntax is calibrated to
> resemble the Example 2.23 on page 118 in the mentioned book of
> Alexander. There is a EXCEL-file coming with the book and I noticed
> that my results don`t match the results of the EXCEL implementation.
>
> e.g. my result for theta=0.001 is
>
> 0.0841052 (method 1) and
>
> 0.0842109 (method 2)
> ... but the EXCEL-file coming with the book says that it was 0.1152
>
>
> setting theta=0.01 gives
>
> 0.04493586 (method 1) and
>
> 0.04490717 (method 2)
>
> ... but the EXCEL-file coming with the book says that it was 0.0616
>
>
> Maybe some of you guys have this book at hand and are able to verify and
> hopefully find a solution for my worries.
> Or even if you don`t have the book you might still be able to assess the
> correctness of my approach and implementation?
>
>
>
>
> ##################################################################################################
> # SET UP MIXTURE INGREDIENTS (calibrate to C.Alexander Market Risk
> Analysis IV Exercise 2.23)
>
> p_quiet <- 0.75
> mu_quiet <- 0.0
> mu_stress <- -0.0004
> df_quiet <- 10
> df_stress <- 5
> variance_quiet <- 0.0126^2
> variance_stress <- 0.0253^2
> theta <- 0.001
>
>
> # METHOD_1) Backing out mixture VaR from implicit analytic formula:
> find_quant <- function(quant) {
> (p_quiet*pdist(distribution = "sstd",
> (quant-mu_quiet)/sqrt(variance_quiet) , mu = 0, sigma = 1, shape =
> df_quiet)
> + (1-p_quiet)*pdist(distribution = "sstd",
> (quant-mu_stress)/sqrt(variance_stress) , mu = 0, sigma = 1, shape =
> df_stress) - theta)
> }
> bestquant <- uniroot(f = find_quant, interval = c(-5, 1))
> t_mix_VaR1 <- -bestquant$root
>
>
> # METHOD_2) Estimating mixture VaR by simulation:
> nsim <- 10000000
> u_mix <- x <- 1*(runif(nsim) < p_quiet)
> t_quiet <- rdist(distribution = "sstd", nsim , mu = mu_quiet, sigma =
> sqrt(variance_quiet), shape = df_quiet)
> t_stress <- rdist(distribution = "sstd", nsim , mu = mu_stress, sigma =
> sqrt(variance_stress), shape = df_stress)
> t_mixture <- u_mix*t_quiet + (1-u_mix)*t_stress
> t_mix_VaR2 <- as.numeric(-quantile( t_mixture , probs=theta ))
>
> # Compare results
> t_mix_VaR1
> t_mix_VaR2
> ##################################################################################################
>
>
>
>
> The EXCEL spreadsheet "EX_IV.2.23" in the workbook "Examples_IV.2.xls"
> has been used and modified as follows:
> 1) change the risk horizon to 1 day (so that there would be no scaling
> and the autocorrelation doesn`t matter)
> 2) if necessary change the significance level (1% or 0,1% in my example)
> 3) press F11 to recalcualte the mixture parameters over the risk horizon
> 4) apply EXCEL SOLVER to line C24 while allowing for changing cell C25
> to get the t Mixture VaR
>
> Thanks a lot for any ideas or suggestions!
> Johannes
>
>
>
>
>
>
>
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>
More information about the R-SIG-Finance
mailing list