Learn R Programming

VaRES (version 1.0.2)

tsp: Two sided power distribution

Description

Computes the pdf, cdf, value at risk and expected shortfall for the two sided power distribution due to van Dorp and Kotz (2002) given by $$\begin{array}{ll} &\displaystyle f (x) = \left\{ \begin{array}{ll} \displaystyle a \left( \frac {x}{\theta} \right)^{a - 1}, & \mbox{if $0 < x \leq \theta$,} \\ \displaystyle a \left( \frac {1 - x}{1 - \theta} \right)^{a - 1}, & \mbox{if $\theta < x < 1$,} \end{array} \right. \\ &\displaystyle F (x) = \left\{ \begin{array}{ll} \displaystyle \theta \left( \frac {x}{\theta} \right)^a, & \mbox{if $0 < x \leq \theta$,} \\ \displaystyle 1 - (1 - \theta) \left( \frac {1 - x}{1 - \theta} \right)^a, & \mbox{if $\theta < x < 1$,} \end{array} \right. \\ &\displaystyle {\rm VaR}_p (X) = \left\{ \begin{array}{ll} \displaystyle \theta \left( \frac {p}{\theta} \right)^{1 / a}, & \mbox{if $0 < p \leq \theta$,} \\ \displaystyle 1 - (1 - \theta) \left( \frac {1 - p}{1 - \theta} \right)^{1 / a}, & \mbox{if $\theta < p < 1$,} \end{array} \right. \\ &\displaystyle {\rm ES}_p (X) = \left\{ \begin{array}{ll} \displaystyle \frac {a \theta}{a + 1} \left( \frac {p}{\theta} \right)^{1 / a}, & \mbox{if $0 < p \leq \theta$,} \\ \displaystyle 1 - \frac {\theta}{p} + \frac {a (2 \theta - 1)}{(a + 1) p} + \frac {a (1 - \theta)^2}{(a + 1) p} \left( \frac {1 - p}{1 - \theta} \right)^{1 + 1 / a}, & \mbox{if $\theta < p < 1$} \end{array} \right. \end{array}$$ for \(0 < x < 1\), \(0 < p < 1\), \(a > 0\), the shape parameter, and \(-\infty < \theta < \infty\), the location parameter.

Usage

dtsp(x, a=1, theta=0.5, log=FALSE)
ptsp(x, a=1, theta=0.5, log.p=FALSE, lower.tail=TRUE)
vartsp(p, a=1, theta=0.5, log.p=FALSE, lower.tail=TRUE)
estsp(p, a=1, theta=0.5)

Value

An object of the same length as x, giving the pdf or cdf values computed at x or an object of the same length as p, giving the values at risk or expected shortfall computed at p.

Arguments

x

scaler or vector of values at which the pdf or cdf needs to be computed

p

scaler or vector of values at which the value at risk or expected shortfall needs to be computed

theta

the value of the location parameter, must take a value in the unit interval, the default is 0.5

a

the value of the shape parameter, must be positive, the default is 1

log

if TRUE then log(pdf) are returned

log.p

if TRUE then log(cdf) are returned and quantiles are computed for exp(p)

lower.tail

if FALSE then 1-cdf are returned and quantiles are computed for 1-p

Author

Saralees Nadarajah

References

Stephen Chan, Saralees Nadarajah & Emmanuel Afuecheta (2016). An R Package for Value at Risk and Expected Shortfall, Communications in Statistics - Simulation and Computation, 45:9, 3416-3434, tools:::Rd_expr_doi("10.1080/03610918.2014.944658")

Examples

Run this code
x=runif(10,min=0,max=1)
dtsp(x)
ptsp(x)
vartsp(x)
estsp(x)

Run the code above in your browser using DataLab