Fits the linear conditional quantile model
\(Q_{y|x}(\tau) = x'\beta(\tau)\) by minimising the check loss
\(\sum_i \rho_\tau(y_i - x_i'\beta)\) (Koenker and Bassett 1978).
method = "fn" is the Frisch-Newton primal-dual interior point
method of Portnoy and Koenker (1997), O(n p^2) per iteration and fast
for n in the hundreds of thousands; method = "br" finishes the
interior point solution with Barrodale-Roberts simplex pivots so that
it returns an exact vertex (basic) solution. Standard errors are
computed as in Koenker (2005, Sec. 3.4): the Hendricks-Koenker
sandwich with the Hall-Sheather bandwidth ("nid"), the iid
sparsity estimate ("iid"), Powell's kernel sandwich
("ker") or the xy-pair bootstrap ("boot").
Usage
morie_rq(
formula,
data,
tau = 0.5,
method = c("fn", "br"),
se = c("nid", "iid", "ker", "boot"),
weights = NULL,
hs = TRUE,
R = 200L,
seed = NULL,
...
)
# S3 method for class 'morie_rq'
print(x, ...)
# S3 method for class 'morie_rq'
summary(object, ...)
# S3 method for class 'summary.morie_rq'
print(x, ...)
# S3 method for class 'morie_rq'
coef(object, ...)
# S3 method for class 'morie_rq'
vcov(object, ...)
# S3 method for class 'morie_rq'
fitted(object, ...)
# S3 method for class 'morie_rq'
residuals(object, ...)
# S3 method for class 'morie_rq'
predict(object, newdata = NULL, ...)
# S3 method for class 'morie_rq'
logLik(object, ...)Arguments
- formula
A model formula, e.g.
y ~ x1 + x2.- data
A data frame holding the variables of
formula.- tau
Quantile(s) in (0, 1); a vector fits each one.
- method
"fn"(Frisch-Newton interior point, default) or"br"(exact vertex solution).- se
Standard error type:
"nid"(default),"iid","ker"or"boot".- weights
Optional non-negative case weights, multiplying rows of the design and the response (as quantreg's
rq.wfit).- hs
Logical; Hall-Sheather bandwidth (TRUE, default) or Bofinger (FALSE) for "nid", "iid" and "ker".
- R
Number of bootstrap replications for
se = "boot".- seed
Optional integer seed for the bootstrap (the caller's random number stream is restored afterwards).
- ...
Unused; accepted for call compatibility.
- x, object
A
"morie_rq"fit.- newdata
Optional data frame for
predict.
Value
An object of class "morie_rq": coefficients
(vector, or p x K matrix for K quantiles), coef_table (list
of Value / Std. Error / t value / Pr(>|t|) tables, one per tau),
vcov (list of covariance matrices), residuals,
fitted.values, rho (check-loss objective), tau,
method, se, nit, n, p,
rdf, terms, xlevels, call.
References
Koenker, R. and Bassett, G. (1978). Regression quantiles. Econometrica 46, 33-50.
Portnoy, S. and Koenker, R. (1997). The Gaussian hare and the Laplacian tortoise: computability of squared-error versus absolute-error estimators. Statistical Science 12(4), 279-300.
Koenker, R. (2005). Quantile Regression. Cambridge University Press.
Hall, P. and Sheather, S. J. (1988). On the distribution of a studentized quantile. JRSS B 50, 381-391.
Examples
set.seed(1)
d <- data.frame(x = runif(200))
d$y <- 1 + 2 * d$x + rnorm(200) * (1 + d$x)
fit <- morie_rq(y ~ x, d, tau = c(0.25, 0.5))
fit
#> Quantile regression (morie native, method fn)
#> Call: morie_rq(formula = y ~ x, data = d, tau = c(0.25, 0.5))
#> n = 200 tau = 0.25, 0.50
#>
#> Coefficients:
#> tau= 0.25 tau= 0.50
#> (Intercept) 0.3039527 0.8303157
#> x 1.5509996 2.1557262
summary(fit)
#> Quantile regression (morie native), standard errors: nid
#> Call: morie_rq(formula = y ~ x, data = d, tau = c(0.25, 0.5))
#>
#> tau: 0.25 (check loss 93.13145)
#> Value Std. Error t value Pr(>|t|)
#> (Intercept) 0.30395 0.22019 1.3804 0.169019
#> x 1.55100 0.54333 2.8546 0.004767 **
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> tau: 0.5 (check loss 116.7703)
#> Value Std. Error t value Pr(>|t|)
#> (Intercept) 0.83032 0.23030 3.6053 0.0003946 ***
#> x 2.15573 0.44738 4.8185 2.872e-06 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Residual df: 198
