# dupsilon: The upsilon distribution. In sadists: Some Additional Distributions

## Description

Density, distribution function, quantile function and random generation for the upsilon distribution.

## Usage

 ```1 2 3 4 5 6 7``` ```dupsilon(x, df, t, log = FALSE, order.max=6) pupsilon(q, df, t, lower.tail = TRUE, log.p = FALSE, order.max=6) qupsilon(p, df, t, lower.tail = TRUE, log.p = FALSE, order.max=6) rupsilon(n, df, t) ```

## Arguments

 `x, q` vector of quantiles. `df` the degrees of freedom in the chi square. a vector. we do not vectorize over this variable. `t` the scaling parameter on the chi. a vector. should be the same length as `df`. we do not vectorize over this variable. `log` logical; if TRUE, densities f are given as log(f). `order.max` the order to use in the approximate density, distribution, and quantile computations, via the Gram-Charlier, Edeworth, or Cornish-Fisher expansion. `p` vector of probabilities. `n` number of observations. `log.p` logical; if TRUE, probabilities p are given as log(p). `lower.tail` logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x].

## Details

Suppose x_i ~ X^2(v_i) independently and independently of Z, a standard normal. Then

Y = Z + sum_i t_i sqrt(x_i/v_i)

takes an upsilon distribution with parameter vectors <v_1, v_2, ..., v_k>, <t_1, t_2, ..., t_k>.

The upsilon distribution is used in certain tests of the Sharpe ratio for independent observations, and generalizes the lambda prime distribution, which can be written as Z + t sqrt(x/v).

## Value

`dupsilon` gives the density, `pupsilon` gives the distribution function, `qupsilon` gives the quantile function, and `rupsilon` generates random deviates.

Invalid arguments will result in return value `NaN` with a warning.

## Note

the PDF and CDF are approximated by an Edgeworth expansion; the quantile function is approximated by a Cornish-Fisher expansion.

The PDF, CDF, and quantile function are approximated, via the Edgeworth or Cornish Fisher approximations, which may not be terribly accurate in the tails of the distribution. You are warned.

The distribution parameters are not recycled with respect to the `x, p, q` or `n` parameters, for, respectively, the density, distribution, quantile and generation functions. This is for simplicity of implementation and performance. It is, however, in contrast to the usual R idiom for dpqr functions.

## Author(s)

Steven E. Pav [email protected]

## References

Lecoutre, Bruno. "Another look at confidence intervals for the noncentral t distribution." Journal of Modern Applied Statistical Methods 6, no. 1 (2007): 107–116. http://www.univ-rouen.fr/LMRS/Persopage/Lecoutre/telechargements/Lecoutre_Another_look-JMSAM2007_6(1).pdf

Lecoutre, Bruno. "Two useful distributions for Bayesian predictive procedures under normal models." Journal of Statistical Planning and Inference 79 (1999): 93–105.

Pav, Steven. "Inference on the Sharpe ratio via the upsilon distribution.' Arxiv (2015). http://arxiv.org/abs/1505.00829

lambda-prime distribution functions, `dlambdap, plambdap, qlambdap, rlambdap`. Sum of chi-squares to power distribution functions, `dsumchisqpow, psumchisqpow, qsumchisqpow, rsumchisqpow`.
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42``` ```mydf <- c(100,30,50) myt <- c(-1,3,5) rv <- rupsilon(500, df=mydf, t=myt) d1 <- dupsilon(rv, df=mydf, t=myt) ## Not run: plot(rv,d1) ## End(Not run) p1 <- pupsilon(rv, df=mydf, t=myt) # should be nearly uniform: ## Not run: plot(ecdf(p1)) ## End(Not run) q1 <- qupsilon(ppoints(length(rv)),df=mydf,t=myt) ## Not run: qqplot(x=rv,y=q1) ## End(Not run) ## Not run: require(SharpeR) ope <- 252 n.sim <- 500 n.term <- 3 set.seed(234234) pp <- replicate(n.sim,{ # these are population parameters a <- rnorm(n.term) psi <- 6 * rnorm(length(a)) / sqrt(ope) b <- sum(a * psi) df <- 100 + ceiling(200 * runif(length(psi))) comm <- 1 / sqrt(sum(a^2 / df)) cdf <- df - 1 # now independent draws from the SR distribution: x <- rsr(length(df), df, zeta=psi, ope=1) # now compute a p-value under the true null pupsilon(comm * b,df=cdf,t=comm*a*x) }) # ought to be uniform: plot(ecdf(pp)) ## End(Not run) ```