equatiomatic icon indicating copy to clipboard operation
equatiomatic copied to clipboard

support for `quantreg::rq` objects

Open fawda123 opened this issue 5 years ago • 5 comments

Hi there, great package! Just a suggestion to add support for quantreg::rq objects.

library(equatiomatic)
library(quantreg)

# Fit a simple model
mod1 <- rq(mpg ~ cyl + disp, data = mtcars)

# Give the results to extract_eq
extract_eq(mod1)

# Error in UseMethod("extract_lhs", model) : 
#  no applicable method for 'extract_lhs' applied to an object of class "rq"

fawda123 avatar Sep 12 '19 23:09 fawda123

Hi, thanks for the suggestion! This is a great idea but, honestly, we're probably a ways away from being able to implement it (and I recognize this issue was opened nearly 11 months ago with no response). I'm hoping to build out a framework to make extensions like this easier, and then to build a vignette on how to implement new equations. That way, others in the community like yourself could help contribute to the package more directly. I'll tag this issue if/when I'm able to do that.

datalorax avatar Jul 26 '20 20:07 datalorax

No worries, feel free to tag me with any updates!

fawda123 avatar Jul 27 '20 12:07 fawda123

Hi @fawda123, could you provide an example of what the equation from the model you showed above should look like? I'm not super familiar with quantile regression.

datalorax avatar Aug 01 '20 17:08 datalorax

@datalorax the equation is the same as for OLS, i.e., response ~ intercept plus slope parameters.

library(quantreg)
mod1 <- rq(mpg ~ cyl + disp, data = mtcars)
summary(mod1)

# Call: rq(formula = mpg ~ cyl + disp, data = mtcars)
# 
# tau: [1] 0.5
# 
# Coefficients:
#   coefficients lower bd upper bd
# (Intercept) 33.32282     27.32925 38.72945
# cyl         -1.58246     -2.66538 -0.55182
# disp        -0.01768     -0.03105 -0.00331

fawda123 avatar Aug 02 '20 12:08 fawda123

Ah... okay. Then yes! This should be pretty easy to implement.

datalorax avatar Aug 02 '20 14:08 datalorax