dupsilon: The upsilon distribution.

View source: R/upsilon.r

upsilonR Documentation

The upsilon distribution.

Description

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

Usage

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 \mbox{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 \mbox{log}(p).

lower.tail

logical; if TRUE (default), probabilities are P[X \le x], otherwise, P[X > x].

Details

Suppose x_i \sim \chi^2\left(\nu_i\right) independently and independently of Z, a standard normal. Then

\Upsilon = Z + \sum_i t_i \sqrt{x_i/\nu_i}

takes an upsilon distribution with parameter vectors [\nu_1, \nu_2, \ldots, \nu_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/\nu}.

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 shabbychef@gmail.com

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. https://digitalcommons.wayne.edu/cgi/viewcontent.cgi?article=1128&context=jmasm

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). https://arxiv.org/abs/1505.00829

See Also

lambda-prime distribution functions, dlambdap, plambdap, qlambdap, rlambdap. Sum of chi-squares to power distribution functions, dsumchisqpow, psumchisqpow, qsumchisqpow, rsumchisqpow.

Examples

mydf <- c(100,30,50)
myt <- c(-1,3,5)
rv <- rupsilon(500, df=mydf, t=myt)
d1 <- dupsilon(rv, df=mydf, t=myt)

plot(rv,d1)

p1 <- pupsilon(rv, df=mydf, t=myt)
# should be nearly uniform:

plot(ecdf(p1))

q1 <- qupsilon(ppoints(length(rv)),df=mydf,t=myt)

qqplot(x=rv,y=q1)


if (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)) 
}


sadists documentation built on Aug. 22, 2023, 1:06 a.m.