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

beta regression is not supported yet #234

Closed
yuryzablotski opened this issue Aug 4, 2023 · 2 comments · Fixed by #233
Closed

beta regression is not supported yet #234

yuryzablotski opened this issue Aug 4, 2023 · 2 comments · Fixed by #233

Comments

@yuryzablotski
Copy link

Hi guys, beta regression can't be processed with tbl_regression(). Would be nice if it worked:

d <- mtcars %>%
mutate(mpg = mpg/100,
cyl = factor(cyl))

library(betareg)
m <- betareg(mpg ~ cyl, data = d)

plot_model(m, type = "pred")

library(emmeans)
emmeans(m, pairwise ~ cyl, type = "response")

library(gtsummary)
tbl_regression(m, add_pairwise_contrasts = T)

The error message on my computer is:

Error in dplyr::left_join():
! Join columns in x must be present in the
data.
✖ Problem with variable.
Backtrace:

  1. gtsummary::tbl_regression(m, add_pairwise_contrasts = T)
  2. dplyr:::left_join.data.frame(...)

Thanks upfront! Love gtsummary!!!

@ddsjoberg
Copy link
Collaborator

Things that work

broom::tidy()
model.matrix()
model.frame()
terms() I didn't inspect the internals of the object though

Things that need to be addressed

  • The (phi) is being incorrectly categorized as the intercept
    image
  • The error is thrown when tidy_add_reference_rows() is run.

@larmarange
Copy link
Owner

I explored quickly beta regression.

By the way, a nice introduction: https://www.andrewheiss.com/blog/2021/11/08/beta-regression-guide/

Beta regression have something similar with zero-inflated Poisson models, there are multi-components models, as you model both the mean and phi, each could have their own coefficients. Here, (phi) is properly interpreted as an intercept, but this is the intercept of another component.

I will therefore explore it and include betareg support in #233. Next week I'll be on leave but will explore it later after the 12 of August.

A related issue for gtsummary is ddsjoberg/gtsummary#1540

Adding pairwise contrasts for such model is another question. Let's start with basic support and then see if pairwise contrast could be added or not.

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 a pull request may close this issue.

3 participants