R: Expectiles of the Uniform Distribution

Expectiles-Uniform {VGAM} | R Documentation

## Expectiles of the Uniform Distribution

### Description

Density function, distribution function, and expectile function and random generation for the distribution associated with the expectiles of a uniform distribution.

### Usage

    deunif(x, min = 0, max = 1, log = FALSE)
    peunif(q, min = 0, max = 1, lower.tail = TRUE, log.p = FALSE)
    qeunif(p, min = 0, max = 1, Maxit.nr = 10, Tol.nr = 1.0e-6,
           lower.tail = TRUE, log.p = FALSE)
    reunif(n, min = 0, max = 1)

### Arguments

`x, q` | Vector of expectiles. See the terminology note below.
`p` | Vector of probabilities. These should lie in (0,1).
`n, min, max, log` | See `runif`.
`lower.tail, log.p` | Same meaning as in `punif` or `qunif`.
`Maxit.nr` | Numeric. Maximum number of Newton-Raphson iterations allowed. A warning is issued if convergence is not obtained for all `p` values.
`Tol.nr` | Numeric. Small positive value specifying the tolerance or precision to which the expectiles are computed.

### Details

Jones (1994) elucidated on the property that the expectiles of a random variable X with distribution function F(x) correspond to the quantiles of a distribution G(x) where G is related by an explicit formula to F. In particular, let y be the p-expectile of F. Then y is the p-quantile of G where

p = G(y) = (P(y) - y F(y)) / (2[P(y) - y F(y)] + y - mu),

and mu is the mean of X. The derivative of G is

g(y) = ( mu F(y) - P(y)) / (2[P(y) - y F(y)] + y - mu)^2 .

Here, P(y) is the partial moment int^{y} x f(x) dx and 0 < p < 1. The 0.5-expectile is the mean mu and the 0.5-quantile is the median.

A note about the terminology used here. Recall in the S language there are the `dpqr`-type functions associated with a distribution, e.g., `dunif`, `punif`, `qunif`, `runif`, for the uniform distribution. Here, `unif` corresponds to F and `eunif` corresponds to G. The addition of “`e`” (for expectile) is for the ‘other’ distribution associated with the parent distribution. Thus `deunif` is for g, `peunif` is for G, `qeunif` is for the inverse of G, `reunif` generates random variates from g.

For `qeunif` the Newton-Raphson algorithm is used to solve for y satisfying p = G(y). Numerical problems may occur when values of `p` are very close to 0 or 1.

### Value

`deunif(x)` gives the density function g(x). `peunif(q)` gives the distribution function G(q). `qeunif(p)` gives the expectile function: the expectile y such that G(y) = p. `reunif(n)` gives n random variates from G.

### Author(s)

T. W. Yee and Kai Huang

### References

Jones, M. C. (1994). Expectiles and M-quantiles are quantiles. Statistics and Probability Letters, 20, 149–153.

Yee, T. W. (2012). Vector generalized linear and additive quantile and expectile regression. In preparation.

### See Also

`deexp`, `denorm`, `dunif`, `dsc.t2`.

### Examples

    my.p <- 0.25; y <- runif(nn <- 1000)
    (myexp <- qeunif(my.p))
    sum(myexp - y[y <= myexp]) / sum(abs(myexp - y))  # Should be my.p
    # Equivalently:
    I1 <- mean(y <= myexp) * mean( myexp - y[y <= myexp])
    I2 <- mean(y >  myexp) * mean(-myexp + y[y >  myexp])
    I1 / (I1 + I2)  # Should be my.p
    # Or:
    I1 <- sum( myexp - y[y <= myexp])
    I2 <- sum(-myexp + y[y >  myexp])

    # Non-standard uniform
    mymin <- 1; mymax <- 8
    yy <- runif(nn, mymin, mymax)
    (myexp <- qeunif(my.p, mymin, mymax))
    sum(myexp - yy[yy <= myexp]) / sum(abs(myexp - yy))  # Should be my.p
    peunif(mymin, mymin, mymax)     #  Should be 0
    peunif(mymax, mymin, mymax)     #  Should be 1
    peunif(mean(yy), mymin, mymax)  #  Should be 0.5
    abs(qeunif(0.5, mymin, mymax) - mean(yy))  #  Should be 0
    abs(qeunif(0.5, mymin, mymax) - (mymin+mymax)/2)  #  Should be 0
    abs(peunif(myexp, mymin, mymax) - my.p)  #  Should be 0
    integrate(f = deunif, lower = mymin - 3, upper = mymax + 3,
              min = mymin, max = mymax)  # Should be 1

    ## Not run:
    par(mfrow = c(2,1))
    yy <- seq(0.0, 1.0, len = nn)
    plot(yy, deunif(yy), type = "l", col = "blue", ylim = c(0, 2),
         xlab = "y", ylab = "g(y)", main = "g(y) for Uniform(0,1)")
    lines(yy, dunif(yy), col = "darkgreen", lty = "dotted", lwd = 2)  # 'original'

    plot(yy, peunif(yy), type = "l", col = "blue", ylim = 0:1,
         xlab = "y", ylab = "G(y)", main = "G(y) for Uniform(0,1)")
    abline(a = 0.0, b = 1.0, col = "darkgreen", lty = "dotted", lwd = 2)
    abline(v = 0.5, h = 0.5, col = "red", lty = "dashed")
    ## End(Not run)

[Package VGAM version 1.1-3 Index]