I was using a function rq()
from the quantreg package. Originally I fit a model with method="br"
and got a warning message that the “solutions may be nonunique”. To suppress this warning, I tried fitting a model with different algorithm method="fn
” and obtained the following results. However, the summary function on the model object (summary(fit)
) yields different coefficients than fit$coefficients
. Is there a way to make the summary function output a solution from the “fn” method rather than “br” method?
library(quantreg)
fit <- rq(y ~ x1 + x2 + x3, method="fn", data=dat, tau=0.5)
> fit$coefficients
(Intercept) x1 x2 x3
9.4021951 25.1791775 14.1790548 0.2947553
> summary(fit)
Call: rq(formula = y ~ x1 + x2 + x3, tau = 0.5, data = dat, method = "fn")
tau: [1] 0.5
Coefficients:
coefficients lower bd upper bd
(Intercept) 9.35716 9.07227 9.85734
x1 25.17918 24.63725 26.15980
x2 14.22409 13.87955 14.43724
x3 0.24972 -0.28967 0.55808
Warning message:
In rq.fit.br(x, y, tau = tau, ci = TRUE, ...) : Solution may be nonunique
Sample data
set.seed(123)
n <- 100
x1 <- runif(100)
x2 <- sample(0:2, n, replace=TRUE)
x3 <- sample(c(0, 1), n, replace=TRUE)
y <- 10 + 25*x1 + 14*x2 + rnorm(n)
dat <- data.frame(y, x1, x2, x3)