Add weight variable and missing data handling options to rwa()#22
Add weight variable and missing data handling options to rwa()#22
Conversation
Co-authored-by: martinctc <17925865+martinctc@users.noreply.github.com>
Co-authored-by: martinctc <17925865+martinctc@users.noreply.github.com>
Co-authored-by: martinctc <17925865+martinctc@users.noreply.github.com>
Co-authored-by: martinctc <17925865+martinctc@users.noreply.github.com>
Co-authored-by: martinctc <17925865+martinctc@users.noreply.github.com>
… consistent Co-authored-by: martinctc <17925865+martinctc@users.noreply.github.com>
Co-authored-by: martinctc <17925865+martinctc@users.noreply.github.com>
Co-authored-by: martinctc <17925865+martinctc@users.noreply.github.com>
Updated in commit af35bb4. The implementation has been refactored to work with the new
The implementation maintains full backward compatibility and resolves the conflicts with the master branch. |
…com/martinctc/rwa into copilot/add-weight-variable-support
There was a problem hiding this comment.
Pull request overview
This PR adds two new parameters to the rwa() function to address user requests for weighted analysis and configurable missing data handling. The implementation adds a use parameter to control how missing data is handled when computing correlations (defaulting to "pairwise.complete.obs" for backward compatibility) and a weight parameter to enable weighted RWA using survey or importance weights. Both features are integrated with the existing bootstrap confidence interval functionality and work exclusively with multiple regression (not logistic regression).
Changes:
- Added
useandweightparameters torwa()andrwa_multiregress()functions with comprehensive validation - Updated bootstrap functions to propagate both parameters through the analysis pipeline
- Added warning when weight/use parameters are used with logistic regression
- Added 217 lines of comprehensive test coverage for both features and their interactions
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| R/rwa.R | Added parameters, validation logic, and warning for logistic regression; passes parameters to sub-functions |
| R/rwa_multiregress.R | Implemented core weighted correlation using cov.wt() and configurable missing data handling |
| R/bootstrap_rwa.R | Updated all bootstrap functions to handle use/weight parameters consistently |
| man/rwa.Rd | Documented new use and weight parameters for main wrapper function |
| man/rwa_multiregress.Rd | Documented new use and weight parameters with examples |
| tests/testthat/test-rwa.R | Added comprehensive test coverage for validation, edge cases, and parameter combinations |
| NEWS.md | Documented new features and improvements |
| NAMESPACE | Added imports for complete.cases and cov.wt |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This branch adds support for weighted analysis and configurable missing data handling in RWA.
Changes
The changes made in this PR are:
useparameter torwa()andrwa_multiregress()to control missing data handling in correlations (defaults to"pairwise.complete.obs"for backward compatibility)weightparameter torwa()andrwa_multiregress()for weighted RWA usingcov.wt()(defaults toNULL)rwa()wrapper function to passuseandweightparameters through torwa_multiregress()cor()optionrwa()wrapper structure from master branchUsage:
Check
roxygen2::roxygenise()has been run prior to merging to ensure that.RdandNAMESPACEfiles are up to date.devtools::check()orrhub::check_for_cran())Change Type
Please check the type of change your PR introduces:
(OPTIONAL) Note
Backward compatible - existing code continues to work unchanged. Both features integrate seamlessly with bootstrap confidence intervals and work only with multiple regression (not logistic regression). Implementation updated to work with the refactored
rwa()wrapper structure from master branch.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.