alsqreg {VGAM} | R Documentation |
Quantile regression using asymmetric least squares error loss.
alsqreg(w=1, method.init=1)
w |
Positive constant controlling the percentile.
The larger the value the larger the fitted percentile value
(the proportion of points below the ``w-regression plane'').
The default value of unity results in the ordinary least squares
(OLS) solution.
|
method.init |
Integer, either 1 or 2 or 3. Initialization method.
Choose another value if convergence fails.
|
This method was proposed by Efron (1991) and full details can
be obtained there.
Equation numbers below refer to that article.
The model is essentially a linear model
(see lm
), however,
the asymmetric squared error loss function for a residual
r is r^2 if r <= 0 and
w*r^2 if r > 0.
The solution is the set of regression coefficients that
minimize the sum of these over the data set, weighted by the
weights
argument (so that it can contain frequencies).
Newton-Raphson estimation is used here.
An object of class "vglmff"
(see vglmff-class
).
The object is used by modelling functions such as vglm
,
and vgam
.
The loglikelihood
slot currently does not return the
log-likelihood but negative the total asymmetric
squared error loss (2.5).
On fitting, the extra
slot has list components "w"
and
"percentile"
. The latter is the percent of observations below
the ``w-regression plane'', which is the fitted values.
One difficulty is finding the w
value giving a specified
percentile. One solution is to fit the model within a root finding
function such as uniroot
; see the example below.
For alsqreg
objects, methods functions for the generic functions
qtplot
and cdf
have not been written yet.
Thomas W. Yee
Efron, B. (1991) Regression percentiles using asymmetric squared error loss. Statistica Sinica, 1, 93–125.
bminz
,
lms.bcn
and similar variants are alternative
methods for quantile regression.
# Example 1 data(bminz) o = with(bminz, order(age)) bminz = bminz[o,] # Sort by age fit = vglm(BMI ~ bs(age), fam=alsqreg(w=0.07), data=bminz) fit # Note "loglikelihood" is -total asymmetric squared error loss (2.5) fit@extra # Gives the w value and the percentile coef(fit) coef(fit, matrix=TRUE) ## Not run: # Quantile plot with(bminz, plot(age, BMI, col="blue", main= paste(round(fit@extra$percentile, dig=1), "percentile curve"))) with(bminz, lines(age, c(fitted(fit)), col="red")) ## End(Not run) # Example 2 # Find the w values that give the 25, 50 and 75 percentiles findw = function(w, percentile=50) { fit = vglm(BMI ~ bs(age), fam=alsqreg(w=w), data=bminz) fit@extra$percentile - percentile } ## Not run: # Quantile plot with(bminz, plot(age, BMI, col="blue", las=1, main= "25, 50 and 75 percentile curves")) ## End(Not run) for(myp in c(25,50,75)) { bestw = uniroot(f=findw, interval=c(1/10^4, 10^4), percentile=myp) fit = vglm(BMI ~ bs(age), fam=alsqreg(w=bestw$root), data=bminz) ## Not run: with(bminz, lines(age, c(fitted(fit)), col="red")) ## End(Not run) }