Description Usage Arguments Author(s) References Examples
This function fits a restricted quantile regression model to avoid crossing of quantile curves.
1 2 3 4 |
formula |
a formula object, with the response on the left of a |
x |
the design matrix. |
y |
the response variable. |
tau |
the quantile(s) to be estimated. |
data |
a data frame in which to interpret the variables named in the formula. |
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
weights |
an optional vector of weights to be used in the fitting process. Should be NULL or a numeric vector. |
na.action |
a function which indicates what should happen when the data contain |
method |
the algorithm used to compute the fit (see |
model |
if |
contrasts |
a list giving contrasts for some or all of the factors default = NULL appearing in the model formula. The elements of the list should have the same name as the variable and should be either a contrast matrix (specifically, any full-rank matrix with as many rows as there are levels in the factor), or else a function to compute such a matrix given the number of levels. |
... |
optional arguments passed to |
Marco Geraci
He X. Quantile curves without crossing. The American Statistician 1997;51(2):186-192.
Koenker R (2013). quantreg: Quantile Regression. R package version 5.05. URL http://CRAN.R-project.org/package=quantreg.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | data(esterase)
# Fit standard quantile regression
fit <- quantreg::rq(Count ~ Esterase, data = esterase, tau = c(.1,.25,.5,.75,.9))
yhat <- fit$fitted.values
# Fit restricted quantile regression
fitr <- rrq(Count ~ Esterase, data = esterase, tau = c(.1,.25,.5,.75,.9))
yhat2 <- predict(fitr)
# Plot results
par(mfrow = c(1, 2))
# Plot regression quantiles
with(esterase, plot(Count ~ Esterase, pch = 16, cex = .8))
apply(yhat, 2, function(y,x) lines(x,y,lwd = 1.5), x = esterase$Esterase)
# Plot restricted regression quantiles
with(esterase, plot(Count ~ Esterase, pch = 16, cex = .8))
apply(yhat2, 2, function(y,x) lines(x,y,lwd = 1.5), x = esterase$Esterase)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.