Estimates the location and scale parameters of a scaled Student t distribution with 2 degrees of freedom, by maximum likelihood estimation.

sc.studentt2(percentile = 50, llocation = "identitylink",
    lscale = "loglink", ilocation = NULL, iscale = NULL,
    imethod = 1, zero = "scale")

Arguments

percentile

A numerical vector containing values between 0 and 100, which are the quantiles and expectiles. They will be returned as `fitted values'.

llocation, lscale

See Links for more choices, and CommonVGAMffArguments.

ilocation, iscale, imethod, zero

See CommonVGAMffArguments for details.

Details

Koenker (1993) solved for the distribution whose quantiles are equal to its expectiles. Its canonical form has mean and mode at 0, and has a heavy tail (in fact, its variance is infinite).

The standard (“canonical”) form of this distribution can be endowed with a location and scale parameter. The standard form has a density that can be written as $$f(z) = 2 / (4 + z^2)^{3/2}$$ for real \(y\). Then \(z = (y-a)/b\) for location and scale parameters \(a\) and \(b > 0\). The mean of \(Y\) is \(a\). By default, \(\eta_1=a)\) and \(\eta_2=\log(b)\). The expectiles/quantiles corresponding to percentile are returned as the fitted values; in particular, percentile = 50 corresponds to the mean (0.5 expectile) and median (0.5 quantile).

Note that if \(Y\) has a standard dsc.t2 then \(Y = \sqrt{2} T_2\) where \(T_2\) has a Student-t distribution with 2 degrees of freedom. The two parameters here can also be estimated using studentt2 by specifying df = 2 and making an adjustment for the scale parameter, however, this VGAM family function is more efficient since the EIM is known (Fisher scoring is implemented.)

Value

An object of class "vglmff" (see vglmff-class). The object is used by modelling functions such as vglm, rrvglm and vgam.

References

Koenker, R. (1993). When are expectiles percentiles? (solution) Econometric Theory, 9, 526–527.

Author

T. W. Yee

See also

Examples

set.seed(123); nn <- 1000
kdata <- data.frame(x2 = sort(runif(nn)))
kdata <- transform(kdata, mylocat = 1 + 3 * x2,
                          myscale = 1)
kdata <- transform(kdata, y = rsc.t2(nn, loc = mylocat, scale = myscale))
fit  <- vglm(y ~ x2, sc.studentt2(perc = c(1, 50, 99)), data = kdata)
fit2 <- vglm(y ~ x2,    studentt2(df = 2), data = kdata)  # 'same' as fit

coef(fit, matrix = TRUE)
#>              location loglink(scale)
#> (Intercept) 0.9681963     -0.0274607
#> x2          3.0650877      0.0000000
head(fitted(fit))
#>          1%       50%      99%
#> 1 -8.612957 0.9696226 10.55220
#> 2 -8.612469 0.9701113 10.55269
#> 3 -8.610731 0.9718487 10.55443
#> 4 -8.603091 0.9794888 10.56207
#> 5 -8.602441 0.9801389 10.56272
#> 6 -8.601795 0.9807844 10.56336
head(predict(fit))
#>       location loglink(scale)
#> [1,] 0.9696226     -0.0274607
#> [2,] 0.9701113     -0.0274607
#> [3,] 0.9718487     -0.0274607
#> [4,] 0.9794888     -0.0274607
#> [5,] 0.9801389     -0.0274607
#> [6,] 0.9807844     -0.0274607

# Nice plot of the results
if (FALSE)  plot(y ~ x2, data = kdata, col = "blue", las = 1,
     sub  = paste("n =", nn),
     main = "Fitted quantiles/expectiles using the sc.studentt2() distribution")
matplot(with(kdata, x2), fitted(fit), add = TRUE, type = "l", lwd = 3)
#> Error in plot.xy(xy.coords(x, y), type = type, ...): plot.new has not been called yet
legend("bottomright", lty = 1:3, lwd = 3, legend = colnames(fitted(fit)),
       col = 1:3)  # \dontrun{}
#> Error in (function (s, units = "user", cex = NULL, font = NULL, vfont = NULL,     ...) {    if (!is.null(vfont))         vfont <- c(typeface = pmatch(vfont[1L], Hershey$typeface),             fontindex = pmatch(vfont[2L], Hershey$fontindex))    .External.graphics(C_strWidth, as.graphicsAnnot(s), pmatch(units,         c("user", "figure", "inches")), cex, font, vfont, ...)})(dots[[1L]][[1L]], cex = dots[[2L]][[1L]], font = dots[[3L]][[1L]],     units = "user"): plot.new has not been called yet

fit@extra$percentile  # Sample quantiles
#>   1%  50%  99% 
#>  0.8 50.6 98.4