Skip to content

Frailty models (Survival package) mismatch SE#1228

Merged
strengejacke merged 3 commits into
mainfrom
strengejacke/issue1201
May 28, 2026
Merged

Frailty models (Survival package) mismatch SE#1228
strengejacke merged 3 commits into
mainfrom
strengejacke/issue1201

Conversation

@strengejacke
Copy link
Copy Markdown
Member

Fixes #1201

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 increments the package version to 0.29.1.3, updates the NEWS.md file to reflect a bug fix for extracting standard errors in survival::coxph() models with frailty terms, and implements the corresponding fix in R/methods_survival.R. It also adds a unit test to verify the fix and cleans up formatting in tests/testthat/test-pca.R. The reviewer identified a critical issue in the newly added test where the rats dataset is used without being loaded or fully qualified, which will cause the test to fail with an object-not-found error.

Comment thread tests/testthat/test-coxph.R Outdated
Comment on lines +5 to +11
data(cancer, package = "survival")
m <- survival::coxph(
survival::Surv(time, status) ~ rx +
survival::frailty.gaussian(litter, df = 13, sparse = FALSE),
rats,
subset = (sex == 'f')
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The test loads the cancer dataset but then attempts to use the rats dataset, which is not loaded. Since survival is not attached at this point in the test file, this will result in an object 'rats' not found error, causing the test to fail. To fix this and maintain consistency with how other datasets (like survival::lung on line 21) are accessed in this file, we should pass survival::rats directly to the data argument and remove the redundant data(cancer, ...) call.

  m <- survival::coxph(
    survival::Surv(time, status) ~ rx +
      survival::frailty.gaussian(litter, df = 13, sparse = FALSE),
    data = survival::rats,
    subset = (sex == "f")
  )

@strengejacke strengejacke merged commit 6870909 into main May 28, 2026
10 of 20 checks passed
@strengejacke strengejacke deleted the strengejacke/issue1201 branch May 28, 2026 09:15
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.

Frailty models (Survival package) mismatch SE

1 participant