1\name{Expectiles-sc.t2} 2\alias{Expectiles-sc.t2} 3\alias{dsc.t2} 4\alias{psc.t2} 5\alias{qsc.t2} 6\alias{rsc.t2} 7\title{ Expectiles/Quantiles of the Scaled Student t Distribution with 2 Df} 8\description{ 9 Density function, distribution function, and 10 quantile/expectile function and random generation for the 11 scaled Student t distribution with 2 degrees of freedom. 12 13 14} 15\usage{ 16dsc.t2(x, location = 0, scale = 1, log = FALSE) 17psc.t2(q, location = 0, scale = 1, lower.tail = TRUE, log.p = FALSE) 18qsc.t2(p, location = 0, scale = 1, lower.tail = TRUE, log.p = FALSE) 19rsc.t2(n, location = 0, scale = 1) 20} 21%- maybe also 'usage' for other objects documented here. 22\arguments{ 23 \item{x, q}{ 24 Vector of expectiles/quantiles. 25 See the terminology note below. 26 27 28 } 29 \item{p}{ 30 Vector of probabilities. % (tau or \eqn{\tau}). 31 These should lie in \eqn{(0,1)}. 32 33 34 } 35 \item{n, log}{See \code{\link[stats:Uniform]{runif}}.} 36 \item{location, scale}{ 37 Location and scale parameters. 38 The latter should have positive values. 39 Values of these vectors are recyled. 40 41 42 } 43 \item{lower.tail, log.p}{ 44 Same meaning as in \code{\link[stats:TDist]{pt}} 45 or \code{\link[stats:TDist]{qt}}. 46 47 48 } 49} 50\details{ 51 A Student-t distribution with 2 degrees of freedom and 52 a scale parameter of \code{sqrt(2)} is equivalent to 53 the standard form of this distribution 54 (called Koenker's distribution below). 55 Further details about this distribution are given in 56 \code{\link{sc.studentt2}}. 57 58 59} 60\value{ 61 \code{dsc.t2(x)} gives the density function. 62 \code{psc.t2(q)} gives the distribution function. 63 \code{qsc.t2(p)} gives the expectile and quantile function. 64 \code{rsc.t2(n)} gives \eqn{n} random variates. 65 66 67} 68\author{ T. W. Yee and Kai Huang } 69 70%\note{ 71%} 72 73\seealso{ 74 \code{\link[stats:TDist]{dt}}, 75 \code{\link{sc.studentt2}}. 76 77 78} 79 80\examples{ 81my.p <- 0.25; y <- rsc.t2(nn <- 5000) 82(myexp <- qsc.t2(my.p)) 83sum(myexp - y[y <= myexp]) / sum(abs(myexp - y)) # Should be my.p 84# Equivalently: 85I1 <- mean(y <= myexp) * mean( myexp - y[y <= myexp]) 86I2 <- mean(y > myexp) * mean(-myexp + y[y > myexp]) 87I1 / (I1 + I2) # Should be my.p 88# Or: 89I1 <- sum( myexp - y[y <= myexp]) 90I2 <- sum(-myexp + y[y > myexp]) 91 92# Non-standard Koenker distribution 93myloc <- 1; myscale <- 2 94yy <- rsc.t2(nn, myloc, myscale) 95(myexp <- qsc.t2(my.p, myloc, myscale)) 96sum(myexp - yy[yy <= myexp]) / sum(abs(myexp - yy)) # Should be my.p 97psc.t2(mean(yy), myloc, myscale) # Should be 0.5 98abs(qsc.t2(0.5, myloc, myscale) - mean(yy)) # Should be 0 99abs(psc.t2(myexp, myloc, myscale) - my.p) # Should be 0 100integrate(f = dsc.t2, lower = -Inf, upper = Inf, 101 locat = myloc, scale = myscale) # Should be 1 102 103y <- seq(-7, 7, len = 201) 104max(abs(dsc.t2(y) - dt(y / sqrt(2), df = 2) / sqrt(2))) # Should be 0 105\dontrun{ plot(y, dsc.t2(y), type = "l", col = "blue", las = 1, 106 ylim = c(0, 0.4), main = "Blue = Koenker; orange = N(0, 1)") 107lines(y, dnorm(y), type = "l", col = "orange") 108abline(h = 0, v = 0, lty = 2) } 109} 110\keyword{distribution} 111