Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for propensity score weight (psw) objects from the propensity package throughout the halfmoon package. The changes enable seamless integration with psw objects while maintaining backward compatibility with numeric weights.
- Modified data generation to preserve psw objects instead of converting to numeric
- Added utility function to extract numeric data from both regular numeric vectors and psw objects
- Updated all weight-handling functions to work with psw objects through the extraction utility
Reviewed Changes
Copilot reviewed 19 out of 21 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| data-raw/nhefs_weights.R | Preserves psw objects from propensity package instead of converting to numeric |
| R/utils.R | Adds extract_weight_data() utility function to handle both numeric and psw weights |
| R/utils-validation.R | Updates weight validation to accept psw objects |
| R/compute_balance.R | Updates all balance functions to extract numeric data from psw weights |
| R/compute_qq.R | Updates weighted_quantile to handle psw weights |
| R/ess.R | Updates effective sample size calculation for psw weights |
| R/check_auc.R | Updates ROC curve functions to handle psw weights |
| R/geom_*.R | Updates all geom functions to extract numeric data from psw weights |
| R/plot_*.R | Updates plotting functions to handle psw weight columns |
| tests/testthat/test-compute_balance.R | Adds comprehensive tests for psw object compatibility |
| tests/testthat/test-geom_*.R | Updates tests with workarounds for pivot_longer compatibility |
| man/*.Rd | Updates documentation examples with psw extraction workarounds |
Comments suppressed due to low confidence (2)
tests/testthat/test-compute_balance.R:1530
- [nitpick] The variable name 'w_cat_ato' is inconsistent with the pattern used elsewhere in the test. Other weight variables use 'w_cat_ate' and 'w_cat_att_none'. Consider using a more descriptive name or ensuring consistency with the naming convention.
weights = nhefs_weights$w_cat_ato
tests/testthat/test-geom_qq2.R:148
- [nitpick] The variable name 'nhefs_for_pivot2' is inconsistent with 'nhefs_for_pivot' used elsewhere. Consider using a consistent naming pattern like 'nhefs_for_pivot' throughout the file.
nhefs_for_pivot2 <- nhefs_weights
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.