qregress: Quantile regression

View source: R/advanced-models.R

qregressR Documentation

Quantile regression

Description

Fits one or several conditional quantile regression models using the optional quantreg package and R4VN model syntax.

Usage

qregress(y,
  ...,
  vars = NULL,
  data = NULL,
  tau = 0.5,
  method = "br",
  se = "nid",
  weights = NULL,
  subset = NULL,
  ref = NULL,
  noconstant = FALSE,
  diagnosis = FALSE,
  level = 0.95,
  digits = 3,
  p_digits = 3,
  show = TRUE,
  console = FALSE)

Arguments

y

Outcome variable or formula.

...

R4VN predictor terms.

vars

Optional vars(...) predictor specification.

data

Data frame or active data.

tau

One or more quantiles strictly between 0 and 1.

method

Algorithm passed to quantreg::rq().

se

Standard-error method passed to summary.rq().

weights, subset, ref, noconstant

Model controls consistent with other R4VN regression commands.

diagnosis

Logical; if TRUE, append quantile-regression diagnostics for the primary quantile, including residual median, MAD, IQR, residual balance around zero, and quantile check loss. Default FALSE.

level, digits, p_digits, show, console

Confidence, formatting and display controls.

Details

The model nearest tau = 0.5 is stored as the primary active model; all requested quantile fits are retained in raw$models.

Value

An R4VN result object, invisibly.

See Also

regress, nlregress

Examples

if (requireNamespace("quantreg", quietly = TRUE)) {
  # Use a reasonably sized, full-rank data set so the example is stable
  # across quantreg and R versions.
  d <- datasets::mtcars
  d$am <- factor(d$am, levels = c(0, 1),
                 labels = c("Automatic", "Manual"))

  # Median regression with one continuous and one categorical predictor.
  qregress(mpg, c.wt, i.am, data = d, tau = .5,
           se = "iid", show = FALSE)

  # Fit several conditional quantiles in one call.
  qregress(mpg, c.wt, i.am, data = d,
           tau = c(.25, .5, .75), se = "iid", show = FALSE)

  # Request the R4VN quantile-regression diagnostic section.
  qregress(mpg, c.wt, i.am, data = d, tau = .5,
           se = "iid", diagnosis = TRUE, show = FALSE)
}

R4VN documentation built on Sept. 30, 2026, 5:13 p.m.