Skip to contents

Thin extender over quantreg::rq for Koenker-Bassett quantile regression at one or more conditional quantiles (Koenker & Bassett, 1978; Koenker, 2005).

Usage

morie_quantile_reg(formula, tau = 0.5, data, ...)

Arguments

formula

A model formula of the form y ~ x1 + x2 + ....

tau

Numeric scalar or vector in (0, 1); the conditional quantile(s) at which to fit the regression (default 0.5, the median).

data

A data frame containing the variables in formula.

...

Further arguments forwarded to quantreg::rq (e.g. subset, weights, na.action, method, model, contrasts).

Value

A list with $method = "quantreg::rq" and $raw (an rq / rqs object with the fitted coefficients at each tau).

Examples

# \donttest{
  if (requireNamespace("quantreg", quietly = TRUE)) {
    set.seed(1)
    n  <- 100
    df <- data.frame(x = stats::rnorm(n))
    df$y <- 1 + 2 * df$x + stats::rnorm(n)
    morie_quantile_reg(y ~ x, tau = c(0.25, 0.5, 0.75), data = df)
  }
#> $method
#> [1] "quantreg::rq"
#> 
#> $raw
#> Call:
#> quantreg::rq(formula = formula, tau = tau, data = data)
#> 
#> Coefficients:
#>             tau= 0.25 tau= 0.50 tau= 0.75
#> (Intercept) 0.3483693 0.8410793  1.551977
#> x           1.9995781 2.0947524  1.947170
#> 
#> Degrees of freedom: 100 total; 98 residual
#> 
# }