1\name{Expectiles-Normal} 2\alias{Expectiles-Normal} 3\alias{enorm} 4\alias{denorm} 5\alias{penorm} 6\alias{qenorm} 7\alias{renorm} 8\title{ Expectiles of the Normal Distribution } 9\description{ 10 Density function, distribution function, and 11 expectile function and random generation for the distribution 12 associated with the expectiles of a normal distribution. 13 14 15} 16\usage{ 17denorm(x, mean = 0, sd = 1, log = FALSE) 18penorm(q, mean = 0, sd = 1, lower.tail = TRUE, log.p = FALSE) 19qenorm(p, mean = 0, sd = 1, Maxit.nr = 10, Tol.nr = 1.0e-6, 20 lower.tail = TRUE, log.p = FALSE) 21renorm(n, mean = 0, sd = 1) 22} 23%- maybe also 'usage' for other objects documented here. 24\arguments{ 25 \item{x, p, q}{ 26 See \code{\link{deunif}}. 27 28 29 } 30 \item{n, mean, sd, log}{ 31 See \code{\link[stats:Normal]{rnorm}}. 32 33 34 } 35 \item{lower.tail, log.p}{ 36 Same meaning as in \code{\link[stats:Normal]{pnorm}} 37 or \code{\link[stats:Normal]{qnorm}}. 38 39 40 } 41 \item{Maxit.nr, Tol.nr}{ 42 See \code{\link{deunif}}. 43 44 45 } 46} 47\details{ 48 49General details are given in \code{\link{deunif}} 50including 51a note regarding the terminology used. 52Here, 53\code{norm} corresponds to the distribution of interest, \eqn{F}, and 54\code{enorm} corresponds to \eqn{G}. 55The addition of ``\code{e}'' is for the `other' 56distribution associated with the parent distribution. 57Thus 58\code{denorm} is for \eqn{g}, 59\code{penorm} is for \eqn{G}, 60\code{qenorm} is for the inverse of \eqn{G}, 61\code{renorm} generates random variates from \eqn{g}. 62 63 64 65For \code{qenorm} the Newton-Raphson algorithm is used to solve for 66\eqn{y} satisfying \eqn{p = G(y)}. 67Numerical problems may occur when values of \code{p} are 68very close to 0 or 1. 69 70 71 72} 73\value{ 74 \code{denorm(x)} gives the density function \eqn{g(x)}. 75 \code{penorm(q)} gives the distribution function \eqn{G(q)}. 76 \code{qenorm(p)} gives the expectile function: 77 the value \eqn{y} such that \eqn{G(y)=p}. 78 \code{renorm(n)} gives \eqn{n} random variates from \eqn{G}. 79 80 81} 82 83%\references{ 84% 85%Jones, M. C. (1994). 86%Expectiles and M-quantiles are quantiles. 87%\emph{Statistics and Probability Letters}, 88%\bold{20}, 149--153. 89% 90%} 91\author{ T. W. Yee and Kai Huang } 92 93%\note{ 94%The ``\code{q}'', as the first character of ``\code{qeunif}'', 95%may be changed to ``\code{e}'' in the future, 96%the reason being to emphasize that the expectiles are returned. 97%Ditto for the argument ``\code{q}'' in \code{peunif}. 98% 99%} 100 101\seealso{ 102 \code{\link{deunif}}, 103 \code{\link{deexp}}, 104 \code{\link{dnorm}}, 105 \code{\link{amlnormal}}, 106 \code{\link{lms.bcn}}. 107 108 109} 110 111\examples{ 112my.p <- 0.25; y <- rnorm(nn <- 1000) 113(myexp <- qenorm(my.p)) 114sum(myexp - y[y <= myexp]) / sum(abs(myexp - y)) # Should be my.p 115 116# Non-standard normal 117mymean <- 1; mysd <- 2 118yy <- rnorm(nn, mymean, mysd) 119(myexp <- qenorm(my.p, mymean, mysd)) 120sum(myexp - yy[yy <= myexp]) / sum(abs(myexp - yy)) # Should be my.p 121penorm(-Inf, mymean, mysd) # Should be 0 122penorm( Inf, mymean, mysd) # Should be 1 123penorm(mean(yy), mymean, mysd) # Should be 0.5 124abs(qenorm(0.5, mymean, mysd) - mean(yy)) # Should be 0 125abs(penorm(myexp, mymean, mysd) - my.p) # Should be 0 126integrate(f = denorm, lower = -Inf, upper = Inf, 127 mymean, mysd) # Should be 1 128 129\dontrun{ 130par(mfrow = c(2, 1)) 131yy <- seq(-3, 3, len = nn) 132plot(yy, denorm(yy), type = "l", col="blue", xlab = "y", ylab = "g(y)", 133 main = "g(y) for N(0,1); dotted green is f(y) = dnorm(y)") 134lines(yy, dnorm(yy), col = "darkgreen", lty = "dotted", lwd = 2) # 'original' 135 136plot(yy, penorm(yy), type = "l", col = "blue", ylim = 0:1, 137 xlab = "y", ylab = "G(y)", main = "G(y) for N(0,1)") 138abline(v = 0, h = 0.5, col = "red", lty = "dashed") 139lines(yy, pnorm(yy), col = "darkgreen", lty = "dotted", lwd = 2) } 140} 141\keyword{distribution} 142 143%# Equivalently: 144%I1 = mean(y <= myexp) * mean( myexp - y[y <= myexp]) 145%I2 = mean(y > myexp) * mean(-myexp + y[y > myexp]) 146%I1 / (I1 + I2) # Should be my.p 147%# Or: 148%I1 = sum( myexp - y[y <= myexp]) 149%I2 = sum(-myexp + y[y > myexp]) 150 151 152 153 154 155