koenker(percentile = 50, llocation = "identitylink", lscale = "loge",
ilocation = NULL, iscale = NULL, imethod = 1, zero = 2)
Links
for more choices,
and CommonVGAMffArguments
.CommonVGAMffArguments
for details."vglmff"
(see vglmff-class
).
The object is used by modelling functions such as vglm
,
rrvglm
and vgam
.
The standard (``canonical'') form of Koenker's
distribution can be endowed with a location and scale parameter.
The standard form has a density
that can be written as
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 Koenker distribution
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
dkoenker
,
studentt2
.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 = rkoenker(nn, loc = mylocat, scale = myscale))
fit <- vglm(y ~ x2, koenker(perc = c(1, 50, 99)), data = kdata, trace = TRUE)
fit2 <- vglm(y ~ x2, studentt2(df = 2), data = kdata, trace = TRUE) # 'same' as fit
coef(fit, matrix = TRUE)
head(fitted(fit))
head(predict(fit))
# Nice plot of the results
plot(y ~ x2, data = kdata, col = "blue", las = 1,
sub = paste("n =", nn),
main = "Fitted quantiles/expectiles using Koenker's distribution")
matplot(with(kdata, x2), fitted(fit), add = TRUE, type = "l", lwd = 3)
legend("bottomright", lty = 1:3, lwd = 3, legend = colnames(fitted(fit)),
col = 1:3)
fit@extra$percentile # Sample quantiles
Run the code above in your browser using DataLab