The quantreg package introduces functions related to the computations of quantile regression models. Among the additional functions, we have the titular anova.rq(), anova.rqs(), and anova.rqlist().
However, ?anova.rqs() and ?anova.rqlist() refer to the description of the anova.rq() function: "Compute test statistics for two or more quantile regression fits."
What are the differences between the mentioned functions?
From what I read, the application of anova() alone to evaluate quantile regression models tests whether the slope coefficients of the examined models can be considered not different across chosen quantiles. For example:
library(quantreg)
n <- 1000
df <- data.frame(
x1 = rnorm(n, 0, 1), # Normal distribution for x1
x2 = runif(n, -1, 1), # Uniform distribution for x2
y = 2 + 1.5 * rnorm(n, 0, 1) + runif(n, -1, 1) # Linear combination with noise for y
)
model1 <- rq(y ~ x1 + x2, tau = 0.25, data = df)
model2 <- rq(y ~ x1 + x2, tau = 0.5, data = df)
In such a situation, both anova(model1, model2) and anova.rq(model1, model2) respectively provide the following answers:
Quantile Regression Analysis of Deviance Table
Model: y ~ x1 + x2
Joint Test of Equality of Slopes: tau in { 0.25 0.5 }
Df Resid Df F value Pr(>F)
1 2 1998 0.346 0.7075
(in this case, the slope coefficients do not differ in those selected quantiles).
However, in the case:
> anova.rqs(model1, model2)
Error in object$coefficients[, i] : incorrect number of dimensions
> anova.rqlist(model1, model2)
Error in formula.default(x) : invalid formula
If we make some changes in the models:
model1 <- rq(y ~ x1 + x2, tau = seq(0.1, 0.9, by = 0.1), data = df)
model2 <- rq(y ~ x1 + x2, tau = seq(0.1, 0.9, by = 0.1), data = df)
and run the functions:
> anova(model1, model2)
Quantile Regression Analysis of Deviance Table
Model: y ~ x1 + x2
Joint Test of Equality of Slopes: tau in { 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 }
Df Resid Df F value Pr(>F)
1 16 8984 0.9169 0.549
> anova.rq(model1, model2)
Error in names[[i]] : subscript out of bounds
> anova.rqs(model1, model2)
Quantile Regression Analysis of Deviance Table
Model: y ~ x1 + x2
Joint Test of Equality of Slopes: tau in { 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 }
Df Resid Df F value Pr(>F)
1 16 8984 0.9169 0.549
> anova.rqlist(model1, model2)
Error in formula.default(x) : invalid formula
Thus, I have the impression that anova() is significantly more versatile than anova.rq() and anova.rqs(). However, I am unsure when anova.rqlist() might be useful.