Skip to content

Weights improvements#33

Merged
malcolmbarrett merged 5 commits intomainfrom
weights_improvements
Jul 31, 2025
Merged

Weights improvements#33
malcolmbarrett merged 5 commits intomainfrom
weights_improvements

Conversation

@malcolmbarrett
Copy link
Copy Markdown
Member

No description provided.

@malcolmbarrett malcolmbarrett requested a review from Copilot July 31, 2025 17:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This pull request enhances the propensity score weighting functions by adding method dispatch support for data frames and GLM objects, improving helper function consistency, and expanding test coverage. It enables users to work directly with fitted models and data frames containing propensity scores, making the API more flexible.

  • Adds data frame and GLM method dispatch for all weight functions (wt_ate, wt_att, wt_atu, wt_atm, wt_ato, wt_entropy)
  • Replaces direct attribute access with helper functions (is_ps_trimmed, is_ps_truncated) for better encapsulation
  • Restricts continuous exposure support to only ATE weights and removes continuous option from other estimands
  • Significantly expands test coverage with edge cases, integration tests, and cross-package comparisons

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/testthat/test-weights.R Replaces attribute access with helper functions and adds extensive tests for new data frame/GLM methods, edge cases, and package comparisons
man/wt_ate.Rd Updates documentation to reflect new method signatures, adds examples for data frame and GLM usage
R/weights.R Implements data frame and GLM methods for all weight functions, adds helper functions for propensity score extraction
R/weights-utils.R Adds length validation function and updates exposure type matching to accept restricted valid types
NAMESPACE Exports new S3 methods for data frame, GLM, and default dispatch
DESCRIPTION Moves tidyselect to Imports and adds new suggested packages for enhanced functionality
Comments suppressed due to low confidence (2)

tests/testthat/test-weights.R:600

  • The test removes the 'exposure_type' parameter but the error message being tested might not be relevant to the actual change. The test should verify that auto-detection fails appropriately for continuous data when continuous is not supported.
  expect_error(

tests/testthat/test-weights.R:1189

  • This test expects an error from wt_ate with an lm object, but lm objects don't inherit from glm, so this should use a different error class or test scenario that actually represents the intended behavior.
  expect_error(

@malcolmbarrett malcolmbarrett merged commit 1600106 into main Jul 31, 2025
6 checks passed
@malcolmbarrett malcolmbarrett deleted the weights_improvements branch July 31, 2025 18:01
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.

2 participants