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 |
n , min , max , log |
See |
lower.tail , log.p |
|
Maxit.nr |
Numeric.
Maximum number of Newton-Raphson iterations allowed.
A warning is issued if convergence is not obtained for all |
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 with distribution function
correspond to the
quantiles of a distribution
where
is related by an explicit formula to
.
In particular, let
be the
-expectile of
.
Then
is the
-quantile of
where
and
is the mean of
.
The derivative of
is
Here, is the partial moment
and
.
The 0.5-expectile is the mean
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 and
eunif
corresponds to .
The addition of “
e
” (for expectile) is for the
‘other’
distribution associated with the parent distribution.
Thus
deunif
is for ,
peunif
is for ,
qeunif
is for the inverse of ,
reunif
generates random variates from .
For qeunif
the Newton-Raphson algorithm is used to solve for
satisfying
.
Numerical problems may occur when values of
p
are
very close to 0 or 1.
Value
deunif(x)
gives the density function .
peunif(q)
gives the distribution function .
qeunif(p)
gives the expectile function:
the expectile such that
.
reunif(n)
gives random variates from
.
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.
See Also
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 = "green", 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 = "green", lty = "dotted", lwd = 2)
abline(v = 0.5, h = 0.5, col = "red", lty = "dashed")
## End(Not run)