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

Should variable be populated for intercept terms? or stay NA as current? #66

Closed
ddsjoberg opened this issue Oct 21, 2020 · 6 comments · Fixed by #68
Closed

Should variable be populated for intercept terms? or stay NA as current? #66

ddsjoberg opened this issue Oct 21, 2020 · 6 comments · Fixed by #68

Comments

@ddsjoberg
Copy link
Collaborator

ddsjoberg commented Oct 21, 2020

I started re-writing the broom.helpers section of tbl_regression() to use tidy_plus_plus() instead of the individual functions. One of the reasons to use plus-plus over a series of other tidy_*() functions, is that it will be easier for me to give users access to the other arguments in tidy_plus_plus() so they can change the resulting table if they like (e.g. adding the informative contrast labels @gorkang are working on).

One sticking point is that I treat the intercept like a variable. For example, users can change the intercept label using tbl_regression(label = list("(Intercept)" ~ "b0", age ~ "Patient Age")). Is there a way where the gtsummary API does not change, and I can use tidy_plus_plus()?

My first thought was to simply have an option in tidy_identify_variables() that populates the intercept variable column with the term name. But I am not sure if this will cause problems with other subsequent functions. What do you think?

@larmarange
Copy link
Owner

I do not think it would be a problem to populate variable column with "(Intercept)".

Let me check

@larmarange
Copy link
Owner

larmarange commented Oct 21, 2020

Dear @ddsjoberg ,

in fact it is already possible. Please note that your label option in gtsummary::tbl_regression() corresponds to var_labels option in tidy_plus_plus()

library(broom.helpers)
mod <- glm(response ~ age + grade, gtsummary::trial, family = binomial)
res <- mod %>% tidy_plus_plus(
  intercept = T, 
  variable_labels = list("(Intercept)" = "custom")
)
res %>% dplyr::select(term, variable, var_label, label)
#> # A tibble: 5 x 4
#>   term        variable var_label label 
#>   <chr>       <chr>    <chr>     <chr> 
#> 1 (Intercept) <NA>     custom    custom
#> 2 age         age      Age       Age   
#> 3 gradeI      grade    Grade     I     
#> 4 gradeII     grade    Grade     II    
#> 5 gradeIII    grade    Grade     III

Created on 2020-10-21 by the reprex package (v0.3.0)

@larmarange
Copy link
Owner

However, it is TRUE that it is not clearly stated in the documentation.

@larmarange
Copy link
Owner

Now, I have also explored the possibility that, for intercepts, variable column will be populated with term content (i.e. for most models it will be "(Intercept"). Few adjustments are required (cf. https://github.com/larmarange/broom.helpers/pull/68/files )

So, it will be a minor break change, but it could be considered.

@larmarange larmarange changed the title New option request in tidy_plus_plus() and tidy_identify_variables()? Should variable be populated for intercept terms? or stay NA as current? Oct 21, 2020
@ddsjoberg
Copy link
Collaborator Author

I like the idea of having the variable column populated. It'll make selecting that variable/term/intercept much easier to do by the name the users are seeing. My vote is to populate it!

Also, I should note that since it's populated in gtsummary, if we choose not to populate, I'll populate it manually after running tidy_plus_plus() so that all of the other tbl_regression() helper functions can select it as they need.

@larmarange
Copy link
Owner

OK decided. PR merged.

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.

2 participants