Skip to content

Feature: add logistic regression and multiple regression as options#23

Closed
Copilot wants to merge 1 commit intofeature/add-logistic-regressionfrom
copilot/sub-pr-7
Closed

Feature: add logistic regression and multiple regression as options#23
Copilot wants to merge 1 commit intofeature/add-logistic-regressionfrom
copilot/sub-pr-7

Conversation

Copy link

Copilot AI commented Jan 22, 2026

Summary

This branch adds logistic regression and multiple regression as distinct analysis methods with automatic detection.

Changes

The changes made in this PR are:

  1. Core functions: Created rwa_logit() for binary outcomes (logistic regression) and rwa_multiregress() for continuous outcomes (multiple regression)
  2. Wrapper function: Converted rwa() to automatically detect method based on outcome variable (2 unique values → logistic, otherwise → multiple regression) with explicit method parameter override
  3. API standardization: Unified output structure across both methods (consistent column naming, rescaled weights sum to 100, lambda matrices)
  4. Numerical stability: Added safeguards in rwa_logit() for edge cases (clipping predictions away from 0/1, zero standard deviation handling)
  5. Documentation: Added comprehensive roxygen2 docs with examples for both functions and new "Regression Methods" vignette
  6. Plotting support: Extended plot_rwa() to handle both regression types with appropriate labeling
  7. Test coverage: Added test suites for logistic regression, integration tests, and validation of numerical edge cases

Usage example:

# Automatic detection - binary outcome uses logistic regression
mtcars$high_mpg <- ifelse(mtcars$mpg > median(mtcars$mpg), 1, 0)
rwa(mtcars, "high_mpg", c("cyl", "disp", "hp", "wt"))

# Automatic detection - continuous outcome uses multiple regression  
rwa(mtcars, "mpg", c("cyl", "disp", "hp", "wt"))

# Explicit method selection
rwa(mtcars, "high_mpg", c("cyl", "disp", "hp", "wt"), method = "logistic")

Check

  • roxygen2::roxygenise() has been run prior to merging to ensure that .Rd and NAMESPACE files are up to date.
  • The R CMD checks pass (at least one or more of devtools::check() or rhub::check_for_cran())

Change Type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature (incl. changes to visualizations)
  • Technical design
  • Build related changes (e.g. tests)
  • Refactoring (no functional changes, no api changes)
  • Code style update (formatting, renaming) or Documentation content changes
  • Other (please describe):

(OPTIONAL) Note

Bootstrap confidence intervals currently only supported for multiple regression (not logistic regression).


💡 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.

Copilot AI changed the title [WIP] Add logistic regression and multiple regression options Feature: add logistic regression and multiple regression as options Jan 22, 2026
Copilot AI requested a review from martinctc January 22, 2026 11:00
@martinctc martinctc closed this Jan 22, 2026
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