Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose "method" arg of quantile_reg #374

Merged
merged 2 commits into from
Sep 9, 2024
Merged

Conversation

dshemetov
Copy link
Contributor

Checklist

Please:

  • Make sure this PR is against "dev", not "main".
  • Request a review from one of the current epipredict main reviewers:
    dajmcdon.
  • Make sure to bump the version number in DESCRIPTION and NEWS.md.
    Always increment the patch version number (the third number), unless you are
    making a release PR from dev to main, in which case increment the minor
    version number (the second number).
  • Describe changes made in NEWS.md, making sure breaking changes
    (backwards-incompatible changes to the documented interface) are noted.
    Collect the changes under the next release number (e.g. if you are on
    0.7.2, then write your changes under the 0.8 heading).
  • Consider pinning the epiprocess version in the DESCRIPTION file if
    • You anticipate breaking changes in epiprocess soon
    • You want to co-develop features in epipredict and epiprocess

Change explanations for reviewer

Allows us to choose the fitting method used by quantilereg::rq.

Magic GitHub syntax to mark associated Issue(s) as resolved when this is merged into the default branch

  • Resolves #{issue number}

@dshemetov dshemetov requested a review from dajmcdon as a code owner September 4, 2024 20:58
@dajmcdon
Copy link
Contributor

dajmcdon commented Sep 4, 2024

@dshemetov

  1. I think you need to add function documentation to get the check to pass.
  2. How key/timely is this change? I don't think it hurts anything, but I'm hoping that quantile regression will be implemented in tidymodels in the near future. (At which point we'll remove this function completely)

@dshemetov
Copy link
Contributor Author

  1. Sounds good
  2. Not too important + I can run tests locally with this branch; do we have a sense for when tidymodels will receive the update?

@dajmcdon
Copy link
Contributor

dajmcdon commented Sep 6, 2024

It'll be long enough that if you want this, we should merge. However, technically, you can already set method = "whatever":

library(epipredict) # dev branch
library(quantreg)

tib <- data.frame(y = rnorm(100), x1 = rnorm(100), x2 = rnorm(100))
rq_spec <- quantile_reg(quantile_levels = c(.1, .5, .9)) %>% 
  set_engine("rq") # default, method = "br"
translate(rq_spec) # what the call will look like
#> quantile reg Model Specification (regression)
#> 
#> Main Arguments:
#>   quantile_levels = c(0.1, 0.5, 0.9)
#> 
#> Computational engine: rq 
#> 
#> Model fit template:
#> quantreg::rq(formula = missing_arg(), data = missing_arg(), weights = missing_arg(), 
#>     tau = c(0.1, 0.5, 0.9), method = "br", na.action = stats::na.omit, 
#>     model = FALSE)

rq_other <- quantile_reg(quantile_levels = c(.1, .5, .9)) %>%
  set_engine(engine = "rq", method = "pfnb") # chosen arbitrarily
translate(rq_other) # what the call will look like
#> quantile reg Model Specification (regression)
#> 
#> Main Arguments:
#>   quantile_levels = c(0.1, 0.5, 0.9)
#> 
#> Engine-Specific Arguments:
#>   method = pfnb
#> 
#> Computational engine: rq 
#> 
#> Model fit template:
#> quantreg::rq(formula = missing_arg(), data = missing_arg(), weights = missing_arg(), 
#>     tau = c(0.1, 0.5, 0.9), method = "pfnb", na.action = stats::na.omit, 
#>     model = FALSE)

f <- fit(rq_other, formula = y ~ ., data = tib)
parsnip::extract_fit_engine(f)$call # to see what it called
#> quantreg::rq(formula = y ~ ., tau = ~c(0.1, 0.5, 0.9), data = data, 
#>     na.action = stats::na.omit, method = ~"pfnb", model = FALSE)

Created on 2024-09-06 with reprex v2.1.1

@dshemetov
Copy link
Contributor Author

Oh huh, well that's good enough for my needs, but might as well merge this, since at least it will be a documented option? Either way, not a big deal.

@dajmcdon dajmcdon merged commit f76961c into dev Sep 9, 2024
2 checks passed
@dajmcdon dajmcdon deleted the ds/quantreg-method branch September 9, 2024 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants