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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
|
\name{Expectiles-Uniform}
\alias{Expectiles-Uniform}
\alias{eunif}
\alias{deunif}
\alias{peunif}
\alias{qeunif}
\alias{reunif}
\title{ 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, log = FALSE)
qeunif(p, min = 0, max = 1, Maxit.nr = 10, Tol.nr = 1.0e-6)
reunif(n, min = 0, max = 1)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
\item{x, q}{
Vector of expectiles.
See the terminology note below.
}
\item{p}{
Vector of probabilities. % (tau or \eqn{\tau}).
These should lie in \eqn{(0,1)}.
}
\item{n, min, max, log}{
See \code{\link[stats:Uniform]{runif}}.
}
\item{Maxit.nr}{
Numeric.
Maximum number of Newton-Raphson iterations allowed.
A warning is issued if convergence is not obtained for all \code{p}
values.
}
\item{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 \eqn{X} with distribution function \eqn{F(x)}
correspond to the
quantiles of a distribution \eqn{G(x)} where
\eqn{G} is related by an explicit formula to \eqn{F}.
In particular, let \eqn{y} be the \eqn{p}-expectile of \eqn{F}.
Then \eqn{y} is the \eqn{p}-quantile of \eqn{G}
where
\deqn{p = G(y) = (P(y) - y F(y)) / (2[P(y) - y F(y)] + y - \mu),}{
p = G(y) = (P(y) - y F(y)) / (2[P(y) - y F(y)] + y - mu),}
and
\eqn{\mu}{mu} is the mean of \eqn{X}.
The derivative of \eqn{G} is
\deqn{g(y) = (\mu F(y) - P(y)) / (2[P(y) - y F(y)] + y - \mu)^2 .}{
g(y) = ( mu F(y) - P(y)) / (2[P(y) - y F(y)] + y - mu)^2 .}
Here, \eqn{P(y)} is the partial moment
\eqn{\int_{-\infty}^{y} x f(x) \, dx}{int^{y} x f(x) dx}
and
\eqn{0 < p < 1}.
The 0.5-expectile is the mean \eqn{\mu}{mu} and
the 0.5-quantile is the median.
A note about the terminology used here.
Recall in the \emph{S} language there are the \code{dpqr}-type functions
associated with a distribution, e.g.,
\code{\link[stats:Uniform]{dunif}},
\code{\link[stats:Uniform]{punif}},
\code{\link[stats:Uniform]{qunif}},
\code{\link[stats:Uniform]{runif}},
for the uniform distribution.
Here,
\code{unif} corresponds to \eqn{F} and
\code{eunif} corresponds to \eqn{G}.
The addition of ``\code{e}'' (for \emph{expectile}) is for the `other'
distribution associated with the parent distribution.
Thus
\code{deunif} is for \eqn{g},
\code{peunif} is for \eqn{G},
\code{qeunif} is for the inverse of \eqn{G},
\code{reunif} generates random variates from \eqn{g}.
For \code{qeunif} the Newton-Raphson algorithm is used to solve for
\eqn{y} satisfying \eqn{p = G(y)}.
Numerical problems may occur when values of \code{p} are
very close to 0 or 1.
}
\value{
\code{deunif(x)} gives the density function \eqn{g(x)}.
\code{peunif(q)} gives the distribution function \eqn{G(q)}.
\code{qeunif(p)} gives the expectile function:
the expectile \eqn{y} such that \eqn{G(y) = p}.
\code{reunif(n)} gives \eqn{n} random variates from \eqn{G}.
}
\references{
Jones, M. C. (1994)
Expectiles and M-quantiles are quantiles.
\emph{Statistics and Probability Letters},
\bold{20}, 149--153.
Yee, T. W. (2012)
Vector generalized linear and additive
quantile and expectile regression.
\emph{In preparation}.
}
\author{ T. W. Yee }
%\note{
%The ``\code{q}'', as the first character of ``\code{qeunif}'',
%may be changed to ``\code{e}'' in the future,
%the reason being to emphasize that the expectiles are returned.
%Ditto for the argument ``\code{q}'' in \code{peunif}.
%
%}
\seealso{
\code{\link{deexp}},
\code{\link{denorm}},
\code{\link{dunif}},
\code{\link{dkoenker}}.
}
\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
\dontrun{
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") }
}
\keyword{distribution}
|