| sqr | R Documentation |
This function computes the spline quantile regression solution SQR, SQR1, or SAR3
on a given set of quantile levels from a regression formula with or without user-supplied smoothing parameter.
SQR represents the regression coefficients as cubic spline functions of the quantile level and employs the L1-norm of their second derivative as roughness penalty.
SQR1 represents the regression coefficients as linear spline functions and employs the total variation of their first derivatives
as roughness penalty. SQR3 also represents the regression coefficients as cubic spline functions but employs the L2-norm of their second
derivatives as roughness penalty. SQR and SQR1 are solved as linear program (LP) using sqr.fit() and
sqr1.fit(), respectively. SQR3 is solved as quadratic program (QP) using sqr3.fit().
sqr(
formula,
tau = seq(0.1, 0.9, 0.2),
tau0 = tau,
spar = NULL,
w = rep(1, length(tau0)),
mthreads = FALSE,
criterion = c("AIC", "BIC", "GIC"),
method = c("sqr", "sqr1", "sqr3"),
type = c("dual", "primal"),
ztol = NULL,
solver = NULL,
interval = NULL,
npar = c(1, 2),
all.knots = FALSE,
control = list(),
data,
subset,
na.action,
model = TRUE
)
formula |
formula object, with the response on the left of a ~ operator, and the terms, separated by + operators, on the right. |
tau |
sequence of quantile levels for evaluation |
tau0 |
sequence of quantile levels for fitting ( |
spar |
smoothing parameter, selected automatically by |
w |
weight sequence in penalty (default = |
mthreads |
if |
criterion |
criterion for smoothing parameter selection ( |
method |
|
type |
type of QP formulation for SQR3: |
ztol |
zero-tolerance parameter to determine the model complexity
(default = |
solver |
|
interval |
interval for |
npar |
experimental parameter (default = 1) |
all.knots |
|
control |
list of control parameters for QP solvers |
data |
data.frame object containing the observations |
subset |
an optional vector specifying a subset of observations to be used |
na.action |
a function to filter missing data (see |
model |
if |
object of sqr.fit(), sqr1.fit(), or sqr3.fit()
library(quantreg)
data(engel)
engel$income <- (engel$income - mean(engel$income))/1000
tau <- seq(0.1,0.9,0.05)
fit <- rq(foodexp ~ income,tau=tau,data=engel)
fit.sqr1 <- sqr(foodexp ~ income,tau=tau,spar=0.5,method="sqr1",data=engel)
fit.sqr3 <- sqr(foodexp ~ income,tau=tau,spar=0.5,method="sqr3",data=engel)
par(mfrow=c(1,1),pty="m",lab=c(10,10,2),mar=c(4,4,2,1)+0.1,las=1)
plot(tau,fit$coef[2,],xlab="Quantile Level",ylab="Coeff1")
lines(tau,fit.sqr1$coef[2,])
lines(tau,fit.sqr3$coef[2,],col=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.