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

Adding gee tidiers #958

Closed
wants to merge 4 commits into from
Closed

Conversation

shah-in-boots
Copy link

Added tidy, glance, and basic augment function for gee. However, as predict() does not currently work for gee::gee(), nor does the model object return the predictor values, augment is limited. In addition, glance() can be improved upon if there are some agreement with how to assess quality of these clusters (such as a Hosmer-Lemeshow test).

Please let me know if anything else is needed.

@shah-in-boots
Copy link
Author

Hi, @simonpcouch I'm struggling to make sure this will merge. I haven't installed all the dependent libraries for the tests (each individual modeling package), which I figured shouldn't cause an error during a CRAN check (but may error locally). However, there is a package dependency called lfe that shows up. I'm not sure how to handle this.

My commit to the gee-tidiers.R is the only change I've made, so not sure if you've seen this error popup.

> checking package dependencies ... ERROR
  Package suggested but not available: 'lfe'
  
  The suggested packages are required for a complete check.
  Checking can be attempted without them by setting the environment
  variable _R_CHECK_FORCE_SUGGESTS_ to a false value.
  
  See section 'The DESCRIPTION file' in the 'Writing R Extensions'
  manual.

1 error x | 0 warnings v | 0 notes v
Error: Error: R CMD check found ERRORs
Execution halted
Error: Process completed with exit code 1.

@simonpcouch
Copy link
Collaborator

Thanks for the PR! Well done.

You're fine to ignore the lfe error—that package was (surprisingly) archived by CRAN this morning. I'm not seeing any new errors/warnings/notes that seem to be from your end.🌼

I'm seeing 22 files changed at the moment, mostly for documentation updates for packages other than gee. Those are likely due to differing installed package versions. Could you roll back .Rd changes that aren't related to gee?

I'm not able to review the PR more fully at the moment, but will get to this as soon as I can!

@simonpcouch
Copy link
Collaborator

Also, could you give a go at unit tests for these tidiers using the modeltests package? An example of what this looks like in broom can be found here. :-)

@simonpcouch
Copy link
Collaborator

Related to bbolker/broom.mixed#110—I'm wondering if these are better suited to broom.mixed.

@shah-in-boots
Copy link
Author

Yeah, I'll add the unit tests as well - thanks for reminding me.

About #bbolker/broom.mixed#110, it should likely go wherever tidy.geeglm() ends up going as well.

@shah-in-boots
Copy link
Author

I believe this is working now - added tests as well. The area of weakness here I believe is glance() and augment(). I'll keep thinking about how to best show model fit summaries on GEEs, and see about writing a workaround for the lack of a predict dispatch method.

#' @template title_desc_tidy
#'
#' @param x A `gee` object returned from a call to [gee::gee()].
#' @param conf.int Logical indicating whether or not to include a confidence
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you use templates for parameter documentation for the standard arguments? See https://github.com/tidymodels/broom/blob/master/R/biglm-tidiers.R#L6 for an example

tibble::as_tibble(rownames = "term") %>%
dplyr::select(-c(`Naive S.E.`, `Naive z`))

# Remove naive estimators
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you expand this comment to include why we should remove the naive estimators?

coefs$conf.high <- coefs$estimate + zstat * coefs$std.error
}

if (exponentiate) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a new approach to coefficient exponentiation which it would be nice to use here. See https://github.com/tidymodels/broom/blob/master/R/biglm-tidiers.R#L57 for an example.

@@ -0,0 +1,28 @@
context("gee-gee")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of testthat version 3 calls to context() are no longer necessary :)


g1 <- gee::gee(mpg ~ wt + hp, id = cyl, data = mtcars, corstr = "exchangeable")

# Tidy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment (and similarly for glance) is probably unnecessary as it is already very clear what your tests do :)

@simonpcouch
Copy link
Collaborator

Closing in favor of bbolker/broom.mixed#110. :)

@simonpcouch simonpcouch closed this Apr 8, 2022
@github-actions
Copy link

This pull request has been automatically locked. If you believe the issue addressed here persists, please file a new PR (with a reprex: https://reprex.tidyverse.org) and link to this one.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants