Skip to contents

Wrapper around survival::survdiff that tests the null hypothesis of equality across strata.

Usage

get_pvalue(
  survfit_object,
  ptype = "All",
  rho = NULL,
  statlist = c("test", "Chisq", "df", "pvalue"),
  ...
)

Arguments

survfit_object

An object of class survfit

ptype

Character vector containing the type of p-value desired. Current options are "Log-Rank" "Wilcoxon" "Tarone-Ware" "Custom" "All". "Custom" allows the user to specify the weights on the Kaplan-Meier estimates using the argument rho. The default is "All" displaying all types possible. When rho is specified in context of "All", also a custom p-value is displayed.

rho

a scalar parameter that controls the type of test.

statlist

Character vector containing the desired information to be displayed. The order of the arguments determines the order in which they are displayed in the final result. Default is the test name ("test"), Chi-squared test statistic ("Chisq"), degrees of freedom ("df") and p-value ("pvalue").

...

other arguments passed on to the method

Value

A data frame with summary measures for the Test of Equality Across Strata

See also

Examples


## general examples
survfit_object <- visR::estimate_KM(data = adtte, strata = "TRTP")
visR::get_pvalue(survfit_object)
#>   Equality across strata  Chisq df p-value
#> 1               Log-Rank 60.270  2  <0.001
#> 2               Wilcoxon 48.023  2  <0.001
#> 3            Tarone-Ware 41.850  2  <0.001
visR::get_pvalue(survfit_object, ptype = "All")
#>   Equality across strata  Chisq df p-value
#> 1               Log-Rank 60.270  2  <0.001
#> 2               Wilcoxon 48.023  2  <0.001
#> 3            Tarone-Ware 41.850  2  <0.001

## examples to obtain specific tests
visR::get_pvalue(survfit_object, ptype = "Log-Rank")
#>   Equality across strata  Chisq df p-value
#> 1               Log-Rank 60.270  2  <0.001
visR::get_pvalue(survfit_object, ptype = "Wilcoxon")
#>   Equality across strata  Chisq df p-value
#> 1               Wilcoxon 48.023  2  <0.001
visR::get_pvalue(survfit_object, ptype = "Tarone-Ware")
#>   Equality across strata  Chisq df p-value
#> 1            Tarone-Ware 41.850  2  <0.001

## Custom example - obtain Harrington and Fleming test
visR::get_pvalue(survfit_object, ptype = "Custom", rho = 1)
#>                  Equality across strata  Chisq df p-value
#> 1 Harrington and Fleming test (rho = 1) 48.023  2  <0.001

## Get specific information and statistics
visR::get_pvalue(survfit_object, ptype = "Log-Rank", statlist = c("test", "Chisq", "df", "pvalue"))
#>   Equality across strata  Chisq df p-value
#> 1               Log-Rank 60.270  2  <0.001
visR::get_pvalue(survfit_object, ptype = "Wilcoxon", statlist = c("pvalue"))
#>   p-value
#> 1  <0.001