| GroupSequentialTest | R Documentation |
Perform group sequential test for a single endpoint based on sequential one-sided p-values at each stages. Selected alpha spending functions, including user-defined functions, are supported. Boundaries are calculated with 'rpact'. At the final analysis, adjustment can be applied for over-running or under-running trial where observed final information is greater or lower than the planned maximum information. See Wassmer & Brannath, 2016, p78f. The test is based on p-values not z statistics because it is easier to not handling direction of alternative hypothesis in current implementation. In addition, only one-sided test is supported which should be sufficient for common use in clinical design.
new()initialize a group sequential test. Now only support one-sided test based on p-values.
GroupSequentialTest$new(
alpha = 0.025,
alpha_spending = c("asP", "asOF", "asUser"),
planned_max_info,
name = "H0",
silent = TRUE
)alphafamilywise error rate
alpha_spendingalpha spending function. Use "asUser"
if custom alpha spending schedule is used.
planned_max_infointeger. Planned maximum number of patients for non-tte endpoints or number of events for tte endpoints
namecharacter. Name of the hypothesis, e.g. endpoint, subgroup, etc. Optional.
silentTRUE if muting all messages.
get_name()get name of hypothesis
GroupSequentialTest$get_name()
get_alpha()get overall alpha
GroupSequentialTest$get_alpha()
set_alpha_spending()set alpha spending function. This is useful when set 'asUser' at the final stage to adjust for an under- or over-running trial.
GroupSequentialTest$set_alpha_spending(asf)
asfcharacter of alpha spending function.
get_alpha_spending()return character of alpha spending function
GroupSequentialTest$get_alpha_spending()
get_max_info()return planned maximum information
GroupSequentialTest$get_max_info()
set_max_info()set planned maximum information. This is used at the final stage to adjust for an under- or over-running trial.
GroupSequentialTest$set_max_info(obs_max_info)
obs_max_infointeger. Maximum information, which could be observed number of patients or events at the final stage.
get_stage()get current stage.
GroupSequentialTest$get_stage()
reset()an object of class GroupSequentialTest is designed to be used
sequentially by calling GroupSequentialTest$test. When all
planned tests are performed, no further analysis could be done. In that
case keep calling GroupSequentialTest$test will trigger an error.
To reuse the object for a new set of staged p-values, call this function
to reset the status to stage 1. See examples. This implementation can
prevent the error that more than the planned number of stages are tested.
GroupSequentialTest$reset()
set_trajectory()save testing result at current stage
GroupSequentialTest$set_trajectory(result, is_final = FALSE)
resulta data frame storing testing result at a stage.
is_finallogical. TRUE if final test for the hypothesis,
FALSE otherwise.
get_trajectory()return testing trajectory until current stage. This function can be called at any stage. See examples.
GroupSequentialTest$get_trajectory()
get_stage_level()compute boundaries given current (potentially updated) settings. It returns different values if settings are changed over time.
GroupSequentialTest$get_stage_level()
test_one()test a hypothesis with the given p-value at current stage
GroupSequentialTest$test_one( p_value, is_final, observed_info, alpha_spent = NA_real_ )
p_valuenumeric. A p-value.
is_finallogical. TRUE if this test is carried out for
the final analysis.
observed_infointeger. Observed information at current stage. It
can be the number of samples (non-tte) or number of events (tte) at test.
If the current stage is final, observed_info will be used to update
planned_max_info, the alpha spending function (typeOfDesign
in rpact) will be updated to 'asUser', and the argument
userAlphaSpending will be used when calling
rpact::getDesignGroupSequential.
alpha_spentnumeric if alpha_spending = "asUser". It must
be between 0 and alpha, the overall alpha of the test.
NA_real_ for other alpha spending functions "asOF" and
"asP".
test()Carry out test based on group sequential design. If p_values
is NULL, dummy values will be use and boundaries are calculated
for users to review.
GroupSequentialTest$test( observed_info, is_final, p_values = NULL, alpha_spent = NULL )
observed_infoa vector of integers, observed information at stages.
is_finallogical vector. TRUE if the test is for the final
analysis.
p_valuesa vector of p-values. If specified, its length should
equal to the length of observed_info.
alpha_spentaccumulative alpha spent at observed information.
It is a numeric vector of values between 0 and 1, and of length that
equals length(observed_info) if alpha-spending
function is "asUser". Otherwise NULL.
print()generic function for print
GroupSequentialTest$print()
clone()The objects of this class are cloneable with this method.
GroupSequentialTest$clone(deep = FALSE)
deepWhether to make a deep clone.
## 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.