Skip to content

Support survdiff() on a survfit object - #320

Open
DanChaltiel wants to merge 1 commit into
therneau:masterfrom
DanChaltiel:patch-survdiff-survfit
Open

Support survdiff() on a survfit object#320
DanChaltiel wants to merge 1 commit into
therneau:masterfrom
DanChaltiel:patch-survdiff-survfit

Conversation

@DanChaltiel

Copy link
Copy Markdown

Dear Pr Therneau,

In my analyses, I almost never calculate a survdiff test without plotting the KM curves.
This results in the formula being written twice in my code, which is tedious and error-prone in case I want to modify it.

Here is a small improvement suggestion where you can use the survfit object directly instead:

library(survival)

survdiff(Surv(time, status) ~ inst, data=lung, rho=.5)$pvalue
#> [1] 0.5903835

km <- survfit(Surv(time, status) ~ inst, lung)
survdiff(km, rho=.5)$pvalue
#> [1] 0.5903835

Created on 2025-07-06 with reprex v2.1.1

Many thanks once more for your work on this exceptionally useful package.

Best regards
Dan

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.

1 participant