pharmaverse / ggsurvfit

http://www.danieldsjoberg.com/ggsurvfit/
Other
67 stars 19 forks source link

Feature request: logrank trend test #153

Closed for8ver3 closed 1 year ago

for8ver3 commented 1 year ago

suggest with add_pvalue(), add an option to get p-value for trend. Similar to the ggsurvplot: test.for.trend

Thanks kindly

ddsjoberg commented 1 year ago

Thanks for the post @for8ver3

Can you please update your post with an example for calculating this p-value I can run on my machine (both data and code), aka a reprex. Please don't include from ggsurvplot if this is a p-value that can be calculated using the survival package, for example.

ddsjoberg commented 1 year ago

Hi @for8ver3 , please feel free to re-open this issue when you have time.

for8ver3 commented 10 months ago

Hi @ddsjoberg , sorry. Now that I have learnt to use reprex...please see output below.

library(reprex)
library(survminer)
#> Loading required package: ggplot2
#> Loading required package: ggpubr
library(survival)
#> 
#> Attaching package: 'survival'
#> The following object is masked from 'package:survminer':
#> 
#>     myeloma
library(ggsurvfit)
data("df_lung")

fit2 <- survfit(Surv(time, status) ~ ph.ecog, df_lung)
ggsurvplot(fit2, df_lung, 
                 risk.table = TRUE, 
                 tables.y.text = F,
                 legend = "none", 
           pval = TRUE,
           test.for.trend = TRUE)


ggsurvplot(fit2, df_lung, 
           risk.table = TRUE, 
           tables.y.text = F,
           legend = "none", 
           pval = TRUE,
           test.for.trend = FALSE)

Created on 2023-08-08 with reprex v2.0.2

ddsjoberg commented 10 months ago

Please don't include from ggsurvplot

I'll need more details on how this p-value is calculated.