Frailty models (Survival package) mismatch SE#1228
Conversation
There was a problem hiding this comment.
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.
| data(cancer, package = "survival") | ||
| m <- survival::coxph( | ||
| survival::Surv(time, status) ~ rx + | ||
| survival::frailty.gaussian(litter, df = 13, sparse = FALSE), | ||
| rats, | ||
| subset = (sex == 'f') | ||
| ) |
There was a problem hiding this comment.
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")
)
Fixes #1201