## Note: examples showed here replicate the results from
## https://www.rpact.org/vignettes/planning/rpact_boundary_update_example/
## Example 1. Generate boundaries for a pre-fix group sequential design
gst <- GroupSequentialTest$new(
alpha = .025, alpha_spending = 'asOF',
planned_max_info = 387)
## without giving p-values, boundaries are returned without actual testing
gst$test(observed_info = c(205, 285, 393), is_final = c(FALSE, FALSE, TRUE))
gst
## Example 2. Calculate boundaries with observed information at stages
## No p-values are provided
## get an error without resetting an used object
try( gst$test(observed_info = 500, is_final = FALSE) )
## reset the object for re-use
gst$reset()
gst$test(observed_info = c(205, 285, 393), is_final = c(FALSE, FALSE, TRUE))
gst
## Example 3. Test stagewise p-values sequentially
gst$reset()
gst$test(observed_info = 205, is_final = FALSE, p_values = .09)
gst$test(285, FALSE, .006)
## print testing trajectory by now
gst
gst$test(393, TRUE, .002)
## print all testing trajectory
gst
## you can also test all stages at once
## the result is the same as calling test() for each of the stages
gst$reset()
gst$test(c(205, 285, 393), c(FALSE, FALSE, TRUE), c(.09, .006, .002))
gst
## Example 4. use user-define alpha spending
gst <- GroupSequentialTest$new(
alpha = .025, alpha_spending = 'asUser',
planned_max_info = 387)
gst$test(
observed_info = c(205, 285, 393),
is_final = c(FALSE, FALSE, TRUE),
alpha_spent = c(.005, .0125, .025))
gst
Run the code above in your browser using DataLab