Skip to content

Discrepancies in reporting for models of class svycoxph#1189

Merged
strengejacke merged 6 commits intomainfrom
strengejacke/issue1174
Feb 9, 2026
Merged

Discrepancies in reporting for models of class svycoxph#1189
strengejacke merged 6 commits intomainfrom
strengejacke/issue1174

Conversation

@strengejacke
Copy link
Copy Markdown
Member

Fixes #1174

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @strengejacke, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where standard errors were not being reported correctly for svycoxph models. The fix involves updating the standard_error.coxph function to properly extract standard errors from the model summary, accounting for cases where robust standard errors are used. Additionally, the PR includes some minor formatting changes to enhance code clarity.

Highlights

  • Fix for svycoxph Models: This PR addresses discrepancies in reporting standard errors for models of class svycoxph, specifically fixing issue Discrepancies in reporting for models of class svycoxph #1174.
  • Standard Error Calculation: The patch modifies the standard_error.coxph function to correctly identify and use robust standard errors when present in the model summary.
  • Code Formatting: Minor formatting adjustments were made to improve code readability, such as adding line breaks in function definitions and removing unnecessary blank lines.
Changelog
  • R/methods_survival.R
    • Modified model_parameters.survfit to improve readability with line breaks.
    • Updated standard_error.coxph to correctly identify and use robust standard errors from the model summary.
    • Minor formatting adjustments in other functions for consistency.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request primarily addresses discrepancies in reporting for svycoxph models by correctly handling robust standard errors in standard_error.coxph. The change correctly identifies whether robust standard errors were used and extracts the appropriate values from the model summary. Most other changes are stylistic, improving code formatting and readability. My feedback focuses on making the standard error extraction more robust by using column names instead of indices, which will improve maintainability.

Comment thread R/methods_survival.R
@strengejacke strengejacke marked this pull request as ready for review February 9, 2026 14:08
@strengejacke strengejacke requested a review from Copilot February 9, 2026 14:09
@strengejacke
Copy link
Copy Markdown
Member Author

@gemini-code-assist review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses an issue with incorrect standard errors for coxph objects, particularly for svycoxph models using robust standard errors. The core logic change in standard_error.coxph correctly identifies and extracts robust standard errors when available. A new ci.coxph method is also introduced to suppress verbose output from these models. The changes are supported by a new test case for svycoxph models.

My review has identified a critical issue in the new test where an undefined variable is used, which will cause the test to fail. Additionally, I've pointed out some stylistic inconsistencies in code formatting that could be addressed to improve maintainability. Overall, the fix itself is correct and valuable, but the test requires a minor correction.

Comment thread tests/testthat/test-coxph.R Outdated
Comment thread R/methods_survival.R
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

Addresses incorrect reporting for survey-weighted Cox models (notably svycoxph) by ensuring robust standard errors (and derived CIs) are used and by suppressing noisy survey design printing during parameter extraction.

Changes:

  • Update standard_error.coxph() to select robust SEs when the fitted model uses robust variance, while silencing summary() output.
  • Add a ci.coxph() method that silences output during CI computation.
  • Add/adjust tests and update NEWS + package version.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/testthat/test-coxph.R Adds a regression test for svycoxph robust SE/CI behavior; minor formatting changes in existing expectations.
R/methods_survival.R Adjusts coxph SE extraction to prefer robust SEs when available; adds ci.coxph wrapper to suppress output.
NEWS.md Documents the bug fix in standard errors for Cox models.
NAMESPACE Registers S3method(ci, coxph).
DESCRIPTION Bumps package version to 0.28.3.2.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/testthat/test-coxph.R
Comment thread tests/testthat/test-coxph.R Outdated
Comment thread tests/testthat/test-coxph.R Outdated
Comment thread NEWS.md Outdated
@strengejacke strengejacke merged commit 6d70fb9 into main Feb 9, 2026
12 of 22 checks passed
@strengejacke strengejacke deleted the strengejacke/issue1174 branch February 9, 2026 18:42
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.

Discrepancies in reporting for models of class svycoxph

2 participants