Skip to contents

Create a cutting test function for use with sim_gs_n()

Usage

create_test(test, ...)

Arguments

test

A test function such as wlr(), maxcombo(), or rmst()

...

Arguments passed to the cutting test function

Value

A function that accepts a data frame of simulated trial data and returns a test result

Examples

# Simulate trial data
trial_data <- sim_pw_surv()

# Cut after 150 events
trial_data_cut <- cut_data_by_event(trial_data, 150)

# Create a cutting test function that can be used by sim_gs_n()
regular_logrank_test <- create_test(wlr, weight = fh(rho = 0, gamma = 0))

# Test the cutting
regular_logrank_test(trial_data_cut)
#> $method
#> [1] "WLR"
#> 
#> $parameter
#> [1] "FH(rho=0, gamma=0)"
#> 
#> $estimate
#> [1] -15.44592
#> 
#> $se
#> [1] 4.430142
#> 
#> $z
#> [1] -3.486553
#> 

# The results are the same as directly calling the function
stopifnot(all.equal(
  regular_logrank_test(trial_data_cut),
  wlr(trial_data_cut, weight = fh(rho = 0, gamma = 0))
))