jtools
jtools copied to clipboard
Summary of quantile regression using conquer algorithm fails
In summ.rq()
, there is a point where it is assumed that there is a p column in the fourth column of the coefficients. For the recently implemented "conquer" algorithm, this is not the case.
library(jtools)
library(quantreg)
n = 2500
dat = data.table(
x = runif(min = 0, max = 1, n = n),
y = factor(sample(c('A','B'), size = 100, replace = TRUE))
)
dat[, z := x * 0.6 + 0.3 * (y == 'B') + rnorm(n = n, mean = 0, sd = 1)]
# "conquer" QR method
qr <- quantreg::rq(z ~ x + y, data=dat, tau = 0.5, method = 'conquer')
jtools::export_summs(qr)
It can be worked around with a check at line 166 of summ_rq.R:
if (ncol(coef(sum)) == 4) {
ps <- coef(sum)[,4]
} else if (ncol(coef(sum)) == 3) {
ps = rep(1, length(ts))
}
Just calling the p-value 1, so it doesn't highlight anything, I'm sure that it's not the best solution.
In trying to probe this, I'm unable to even get the code to run due to an error occurring within the conquer
package.
library(jtools)
library(quantreg)
library(data.table)
n = 2500
dat = data.table(
x = runif(min = 0, max = 1, n = n),
y = factor(sample(c('A','B'), size = 100, replace = TRUE))
)
dat[, z := x * 0.6 + 0.3 * (y == 'B') + rnorm(n = n, mean = 0, sd = 1)]
qr <- quantreg::rq(z ~ x + y, data=dat, tau = 0.5, method = 'conquer')
#> Error in match.arg(kernel) : 'arg' must be of length 1
This is true for all examples I can test fitting rq
models. Could be an issue with my configuration, but for now I'm reticent to try to fix the underlying bug with jtools
when I can't actually produce an rq
model without p-values to test my work.
Thanks Jacob, I'm getting that error now too. Evidently it's not a very mature technique (and I had to ditch it for other reasons).