Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 18, 2026

Implements simultaneous construction and side-by-side comparison of univariate (each predictor separately) and multivariate (all predictors together) regression models, similar to autoReg package functionality.

Changes

  • br_compare_models(): Builds both model types in one call, returns breg_comparison object with combined results tagged by mode
  • br_show_forest_comparison(): Renders forest plot with univariate and multivariate estimates grouped by variable
  • print.breg_comparison(): S3 print method for comparison objects

Usage

comparison <- br_compare_models(
  lung,
  y = c("time", "status"),
  x = c("ph.ecog", "ph.karno", "pat.karno"),
  x2 = c("age", "sex"),
  method = "coxph"
)

br_show_forest_comparison(comparison)

The forest plot displays each variable's estimates from both models, showing how effects change when adjusted for other predictors (e.g., ph.karno: HR=0.988, p=0.04 univariate → HR=1.02, p=0.11 multivariate).

Works with all model types (Cox, logistic, linear) and handles continuous/categorical variables. Added 12 tests covering various scenarios.

Original prompt

This section details on the original issue you should resolve

<issue_title>针对单变量和多变量模型的同时构建和对比也比较有用</issue_title>
<issue_description>这个有点 out scope,但一些东西是相通的。

https://github.com/cardiomoon/autoReg/blob/main/man/figures/unnamed-chunk-22-1.png</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits January 18, 2026 05:45
Co-authored-by: ShixiangWang <25057508+ShixiangWang@users.noreply.github.com>
Co-authored-by: ShixiangWang <25057508+ShixiangWang@users.noreply.github.com>
Co-authored-by: ShixiangWang <25057508+ShixiangWang@users.noreply.github.com>
Co-authored-by: ShixiangWang <25057508+ShixiangWang@users.noreply.github.com>
Copilot AI changed the title [WIP] Add construction and comparison of single and multiple variable models Add univariate vs multivariate model comparison Jan 18, 2026
Copilot AI requested a review from ShixiangWang January 18, 2026 05:58
Refactored R/08-compare.R for improved code clarity and consistency, mainly adjusting whitespace and minor formatting. Deleted the generated README.html file. Updated related test files to align with the refactored code.
@ShixiangWang ShixiangWang marked this pull request as ready for review January 18, 2026 06:44
Updated the DESCRIPTION file to suggest 'qs2' instead of 'qs'. Modified R/03-accessors.R to use 'qs2::qread' and check for 'qs2' package instead of 'qs'. This ensures compatibility with the 'qs2' package for model reading functionality.
Updated code to use the qs2 package instead of the deprecated qs package. Changed function calls from qs2::qsave/qread to qs2::qs_save/qs_read in pipeline and accessor functions. Updated NEWS.md to document the change.
@ShixiangWang ShixiangWang merged commit 00c5f75 into main Jan 18, 2026
6 checks passed
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