[R-SIG-Finance] RUGARCH --- "pdist" peculiarities wrt. a numerical optimization problem

alexios ghalanos alexios at 4dscape.com
Thu Apr 24 23:44:40 CEST 2014


Try again:


find_quant <- function(quant) {
0.5*pdist( distribution = "norm" , quant, mu = 0 , sigma =1)+0.5*pdist(
distribution = "norm" , quant, mu = 0 , sigma = 1) - 0.01
}

Your code had a space in the wrong place and the function evaluated only
the second line.

Alexios


On 24/04/2014 22:35, Johannes Moser wrote:
> Dear R-Users and Contributors,
> 
> to back out a Value at Risk quantile from a student t mixture
> distribution need to utilize standardized student t distributions (mean
> zero, unti variance).
> However, there seems to be an issue when working with the pdist-function
> implemented in the RUGARCH-package (and to my knowledge this is the only
> implementation of a standardized student t distribution in R).
> 
> My problem can easier be demonstrated by means of a standard normal
> distribution:
> 
> 
> ###########################################################################
> 
> ### direct way to the 1% standard normal quantile
> qnorm( 0.01 , 0 , 1 )
> 
> 
> ### indirect way (leads nearly to the same result)
> find_quant <- function(quant) {
>      pdist( distribution = "norm" , quant, mu = 0 , sigma = 1) - 0.01
> }
> bestquant <- uniroot(f = find_quant, interval = c(-5, 2)); bestquant$root
> 
> 
> ### this should give the same result, BUT IT DOES NOT ???
> find_quant <- function(quant) {
>      0.5*pdist( distribution = "norm" , quant, mu = 0 , sigma = 1)
>      + 0.5*pdist( distribution = "norm" , quant, mu = 0 , sigma = 1) - 0.01
> }
> bestquant <- uniroot(f = find_quant, interval = c(-5, 2)); bestquant$root
> # interestingly, the result changes when modifying the mixing law to
> e.g. 0.1 and 0.9, respectively.
> 
> 
> ### using the R-base functions, there seems to be no problem here:
> find_quant <- function(quant) {
>      0.5*pnorm(quant,0,1) + 0.5*pnorm(quant,0,1) - 0.01
> }
> bestquant <- uniroot(f = find_quant, interval = c(-5, 2)); bestquant$root
> # this method gives the correct result and is insensitive to the mixing
> law.
> # however, as mentioned above, I have to do a similar thing using a
> standardized student t
> # distribution which is not implemented in base R.
> 
> ###########################################################################
> 
> 
> Thanks a lot for any ideas or suggestions!!
> Best,
> Johannes
> 
> _______________________________________________
> 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