Learn R Programming

qfa (version 4.1)

sqr: Spline Quantile Regression (SQR) by formula

Description

This function computes spline quantile regression (SQR) solution from response vector and design matrix. It uses the FORTRAN code rqfnb.f in the "quantreg" package with the kind permission of Dr. R. Koenker.

Usage

sqr(
  formula,
  tau = seq(0.1, 0.9, 0.2),
  spar = NULL,
  d = 1,
  data,
  subset,
  na.action,
  model = TRUE,
  weighted = FALSE,
  mthreads = TRUE,
  method = c("AIC", "BIC"),
  ztol = 1e-05
)

Value

object of SQR fit

Arguments

formula

a 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 in (0,1)

spar

smoothing parameter: if spar=NULL, smoothing parameter is selected by method

d

subsampling rate of quantile levels (default = 1)

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

na.action

a function to filter missing data (see rq in the 'quantreg' package)

model

if TRUE then the model frame is returned (needed for calling summary subsequently)

weighted

if TRUE, penalty function is weighted (default = FALSE)

mthreads

if FALSE, set RhpcBLASctl::blas_set_num_threads(1) (default = TRUE)

method

a criterion for smoothing parameter selection if spar=NULL ("AIC" or "BIC")

ztol

a zero tolerance parameter used to determine the effective dimensionality of the fit

Examples

Run this code
library(quantreg)
data(engel)
engel$income <- engel$income - mean(engel$income)
tau <- seq(0.1,0.9,0.05)
fit <- rq(foodexp ~ income,tau=tau,data=engel)
fit.sqr <- sqr(foodexp ~ income,tau=tau,spar=0.5,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.sqr$coef[2,])

Run the code above in your browser using DataLab