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

add make_dummy_vars argument #7

Merged
merged 2 commits into from
Aug 14, 2022
Merged

add make_dummy_vars argument #7

merged 2 commits into from
Aug 14, 2022

Conversation

malcolmbarrett
Copy link
Collaborator

@malcolmbarrett malcolmbarrett commented Aug 12, 2022

Closes #6

@LucyMcGowan, what do you think? Do regression-style dummy variables make sense, or should there be a dummy variable for every level? e.g. education1 is not included here because it's the comparison/base level

library(tidysmd)

plot_df <- tidy_smd(
  nhefs_weights,
  c(age, race, education),
  .group = qsmk,
  .wts = w_ate
)

love_plot(plot_df)

plot_df_dummies <- tidy_smd(
  nhefs_weights,
  c(age, race, education),
  .group = qsmk,
  .wts = w_ate,
  dummy_variable = TRUE
)

love_plot(plot_df_dummies)

Created on 2022-08-12 by the reprex package (v2.0.1)

@LucyMcGowan
Copy link

This looks awesome. I am trying to think about the argument name since it is likely to update multiple variables? So something like make_dummy or just dummy? (Maybe this is silly!)

@LucyMcGowan
Copy link

Patrick laughed out loud at make_dummy so maybe not 🙃

@malcolmbarrett
Copy link
Collaborator Author

Haha maybe ‘make_dummy_vars’. I like a verb here because the original name sort of sounds like it should be the names of dummy variables.

To confirm, you’re okay with these contrasts? E.g. that there’s no education1 (as there wouldn’t be in regression)?

@LucyMcGowan
Copy link

Yes! I think that makes sense. The referent is the same as would be picked from a model?

@malcolmbarrett
Copy link
Collaborator Author

Right, it uses model.matrix() to create them, as do lm() and friends. Likewise, you can change the reference group the same was as in a model:

library(tidysmd)

# make "graduated high school" the reference group
nhefs_weights$education <- relevel(nhefs_weights$education, ref = "3")
  
plot_df_dummies <- tidy_smd(
  nhefs_weights,
  c(age, race, education),
  .group = qsmk,
  .wts = w_ate,
  make_dummy_vars = TRUE
)

love_plot(plot_df_dummies)

Created on 2022-08-13 by the reprex package (v2.0.1)

@malcolmbarrett malcolmbarrett changed the title add dummy_variable argument add make_dummy_vars argument Aug 14, 2022
@malcolmbarrett malcolmbarrett merged commit e00a1dd into main Aug 14, 2022
@malcolmbarrett malcolmbarrett deleted the dummy_variables branch August 14, 2022 00:24
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.

Look into smds for categorical variables
2 participants