[R-SIG-Finance] fPortfolio inverse VaR function

Henry Ward henry.ward at me.com
Wed Mar 30 19:42:59 CEST 2011


Brian,

Thank you, this is exactly what I need.  I had a sneaking suspicion you had already done this. :)  Another shout-out for your very useful package.  Thanks.

Henry




On Mar 30, 2011, at 10:34 AM, Brian G. Peterson wrote:

> On 03/30/2011 12:19 PM, Henry Ward wrote:
>> Hi members,
>> 
>> I am using fPortfolio (great package) to do Cornish Fisher VaR calculations.  I'm interested in also using the inverse function.  So instead of calculating the p=95% ->  VaR = 2.4% I'd like to assign a VaR threshold of VaR = 2.4% ->  p=95%.
>> 
>> This is the simple qnorm function for gaussian distributions but I want to use Brian's implementation of the Cornish Fisher distribution.  Any help on a simple way I can write or find this function?
> 
> There are functions in PerformanceAnalytics that are not yet documented and exported to do this.
> 
> These are available in this source file here:
> 
> https://r-forge.r-project.org/scm/viewvc.php/pkg/PerformanceAnalytics/R/valueAtRiskFunctions.r?view=markup&root=returnanalytics
> 
> Given a specific shape (mean, variance, skewness, kurtosis) the full quantile and density functions for the Cornish Fisher distribution may be calculated via the bootstrap.  If you really just want the opposite quantile, you can calculate it like this:
> 
>  zc = qnorm(tail.prob)
>  Zcf = zc + (((zc^2 - 1) * skew)/6) + (((zc^3 - 3 * zc) *
>                kurt)/24) - ((((2 * zc^3) - 5 * zc) * skew^2)/36)
>  mVaR = mu + sigma*Zcf
> 
> where tail.prob is the usual 1-confidence, so for 95% VaR (loss) you'd use .05, and for the opposite end of the distribution you would use .95
> 
> We don't allow this in the VaR function because we got too many confused emails, instead we document it as not allowed. ;)
> 
> Cheers,
> 
>  - Brian
> 
> -- 
> Brian G. Peterson
> http://braverock.com/brian/
> Ph: 773-459-4973
> IM: bgpbraverock



More information about the R-SIG-Finance mailing list