Skip to contents

This function compares survival curves as modeled with do_kpm(). It outputs a contingency table and a Chisq measure of difference.

Usage

get_survdiff(kds, cond, test_type)

Arguments

kds

data set of a survival model such as do_kpm()

cond

character of experimental condition variable in the data

test_type

numeric (0 or 1) parameter that controls the type of test (0 means rho = 0; log-rank, 1 means rho = 1; Peto & Peto Wilcox)

Value

Returns survival test results as called from survival::survdiff().

Examples

kpm_est <- do_kpm(add_dropout_idx(dropRdemo, 3:54))
get_survdiff(kpm_est$d, "experimental_condition", 0)
#> Call:
#> survdiff(formula = f, data = kds, rho = test_type)
#> 
#>                            N Observed Expected (O-E)^2/E (O-E)^2/V
#> experimental_condition=11 72       72     72.1  0.000148  0.000358
#> experimental_condition=12 57       56     50.1  0.689840  1.587210
#> experimental_condition=21 56       56     58.2  0.084353  0.185905
#> experimental_condition=22 61       61     64.6  0.196369  0.443239
#> 
#>  Chisq= 1.8  on 3 degrees of freedom, p= 0.6 
get_survdiff(kpm_est$d, "experimental_condition", 1)
#> Call:
#> survdiff(formula = f, data = kds, rho = test_type)
#> 
#>                            N Observed Expected (O-E)^2/E (O-E)^2/V
#> experimental_condition=11 72     50.5     49.8   0.00726    0.0278
#> experimental_condition=12 57     44.9     38.3   1.12936    3.9254
#> experimental_condition=21 56     37.5     39.3   0.08966    0.3173
#> experimental_condition=22 61     37.9     43.2   0.64983    2.3712
#> 
#>  Chisq= 5.1  on 3 degrees of freedom, p= 0.2