Planning, Monitoring, and Analyses using impart
impart
impart
and future directionsimpart
devtools
package if not already installeddevtools::install_github
to install impart
:library()
# Compute Power: Fixed Sample Size
n_7.5 <-
pwr::pwr.t.test(
n = NULL,
d = minimum_difference/7.5, # SD = 7.5
sig.level = alpha,
power = power
)
n_7.5
##
## Two-sample t test power calculation
##
## n = 48.26427
## d = 0.6666667
## sig.level = 0.05
## power = 0.9
## alternative = two.sided
##
## NOTE: n is number in *each* group
required_information_single_stage
: Compute target information level
delta
: Estimand under alternative hypothesis of interestinformation_to_n_continuous_1_to_1
: Continuous Difference in Means# 20% Relative Efficiency Increase from Covariates
relative_efficiency <- c(1, 1.10, 1.20)
# Information From Final Outcomes + Covariates
impart::information_to_n_continuous_1_to_1(
information = information_single_stage/relative_efficiency,
sigma_0 = 10,
sigma_1 = 10,
round_up = TRUE
)
## information sigma_0 sigma_1 n_per_arm n_total
## 1 0.4202969 10 10 85 170
## 2 0.3820881 10 10 77 154
## 3 0.3502474 10 10 71 142
rpact
Package in R: Review of GSDs; Web Book on GSDsrpact::getDesignGroupSequential()
: Set up design with Spending Functionsinformation_rates <- c(0.50, 0.75, 1.00) # Analyses at 50%, 75%, and 100% of the Total Information
type_of_design <- "asOF" # O'Brien-Fleming Alpha Spending: "asP", "asKD" or "asHSD"
type_beta_spending <- "bsOF" # O'Brien-Fleming Beta Spending: "none", "bsP", "bsKD" or "bsHSD"
trial_design <-
rpact::getDesignGroupSequential(
alpha = alpha,
beta = 1 - power,
sided = 2,
informationRates = information_rates,
typeOfDesign = type_of_design,
typeBetaSpending = type_beta_spending,
bindingFutility = FALSE
)
required_information_sequential
: Adjust target for multiplicity# Inflate information level to account for multiple testing
information_multi_stage <-
impart::required_information_sequential(
information_single_stage = information_single_stage,
trial_design = trial_design
)
information_multi_stage
## [1] 0.4558286
# Inflation Factor
information_multi_stage/information_single_stage
## [1] 1.084539
# Target Information Levels for Analyses
information_multi_stage*information_rates
## [1] 0.2279143 0.3418714 0.4558286
impart
impart
in the futurepwr
package: install.packages("pwr")
impart::required_information_single_stage
pwr::pwr.2p.test
using effect size pwr::ES.h()
impart::information_to_n_binary_1_to_1
monitored_design
object: initialize_monitored_design()
example_1
- Continuous Outcome: 30, 60, 90, and 120 days post randomizationhead(example_1)
## .id x_1 x_2 x_3 x_4 tx y_1 y_2
## 1 1 2.0742970 0.1971432 -0.8425884 0.2794844 0 NA NA
## 2 2 0.2165473 -0.7384296 0.1315016 -1.2419134 0 -2.376967 -2.575398
## 3 3 0.8294726 0.4997821 1.6932555 -0.4063889 1 2.094655 13.615512
## 4 4 -1.0206893 -0.2189937 -1.7719120 0.1936013 1 -6.433176 3.015335
## 5 5 -0.0417332 0.9282685 0.8078133 0.9317145 1 5.653307 8.839702
## 6 6 0.7275778 1.1756811 0.0226265 -0.2556343 0 NA NA
## y_3 y_4 .enrollment_time .t_1 .t_2 .t_3 .t_4
## 1 NA NA 33.28136 77.28136 107.28136 137.2814 167.2814
## 2 NA NA 33.69242 74.02729 96.49186 137.6924 167.6924
## 3 20.402979 24.403011 37.69694 73.32954 102.44161 129.2825 152.6411
## 4 5.473575 -6.548695 39.40100 78.95480 95.29012 123.9621 156.4938
## 5 21.906824 4.005459 41.32190 71.43593 102.43171 141.4073 150.4507
## 6 NA NA 55.24537 99.24537 129.24537 159.2454 189.2454
.id
x_1
, x_2
, …, x_4
; Treatment assignment tx
.enrollment_time
y_1
, y_2
, y_3
and y_4
assessed at times .t_1
, .t_2
, .t_3
and .t_4
prepared_final_data <-
prepare_monitored_study_data(
data = example_1,
study_time = 2075, # Days: Study Initiation to Data Lock
id_variable = ".id",
covariates_variables = c("x_1", "x_2", "x_3", "x_4"),
enrollment_time_variable = ".enrollment_time",
treatment_variable = "tx",
outcome_variables = c("y_1", "y_2", "y_3", "y_4"),
outcome_time_variables = c(".t_1", ".t_2", ".t_3", ".t_4"),
# Observe missingness 1 week after target study visit
observe_missing_times = c(30, 60, 90, 120) + 7
)
names(prepared_final_data)
## [1] "data" "original_data" "variables" "study_time"
impart
functions with a prepared_data
argumentcount_outcomes
: Returns a data.frame
with the study time of each eventexample_1_counts <-
count_outcomes(
prepared_data = prepared_final_data
)
head(example_1_counts)
## event time count_total count_complete
## 1 randomization 33.28136 1 1
## 2 randomization 33.69242 2 2
## 3 randomization 37.69694 3 3
## 4 randomization 39.40100 4 4
## 5 randomization 41.32190 5 5
## 6 randomization 55.24537 6 6
data_at_time_t
: Revert a prepared dataset to time \(t^{*}\)data_at_time_t()
example_1
at 90 days after study initiationdata_90 <-
data_at_time_t(
prepared_data = prepared_final_data,
study_time = 90
)
head(data_90$data[, 1:10], n = 6)
## .id x_1 x_2 x_3 x_4 tx .e .r_1 .t_1 y_1
## 1 1 2.0742970 0.1971432 -0.8425884 0.2794844 0 33.28136 0 77.28136 NA
## 2 2 0.2165473 -0.7384296 0.1315016 -1.2419134 0 33.69242 1 74.02729 -2.376967
## 3 3 0.8294726 0.4997821 1.6932555 -0.4063889 1 37.69694 1 73.32954 2.094655
## 4 4 -1.0206893 -0.2189937 -1.7719120 0.1936013 1 39.40100 1 78.95480 -6.433176
## 5 5 -0.0417332 0.9282685 0.8078133 0.9317145 1 41.32190 1 71.43593 5.653307
## 6 6 0.7275778 1.1756811 0.0226265 -0.2556343 0 55.24537 NA NA NA
.r_1
is 0
.r_1
is 1
.r_1
is NA
estimation_function
: Any function that returns "estimate"
estimation_arguments
: List of any arguments for estimation_function
information_n_60 <-
estimate_information(
data = data_n_60,
monitored_design = NULL, # Pass previous analyses in multi-stage designs
estimation_function = standardization,
estimation_arguments =
list(
estimand = "difference",
y0_formula = y_4 ~ x_1 + x_2 + x_3 + x_4,
y1_formula = y_4 ~ x_1 + x_2 + x_3 + x_4,
family = gaussian,
treatment_column = "tx",
outcome_indicator_column = ".r_4"
),
orthogonalize = TRUE,
return_results = TRUE, # FALSE: return only covariance & information
rng_seed = 23456
)
data_n_60_trajectory <-
information_trajectory(
prepared_data = data_n_final_60,
monitored_design = NULL,
estimation_function = standardization,
estimation_arguments =
list(
estimand = "difference",
y0_formula = y_4 ~ x_1 + x_2 + x_3 + x_4,
y1_formula = y_4 ~ x_1 + x_2 + x_3 + x_4,
family = gaussian,
treatment_column = "tx",
outcome_indicator_column = ".r_4"
),
orthogonalize = TRUE,
n_min = 30, # Start at `n_min` primary outcomes
n_increment = 2, # Increment forward
rng_seed = 23456
)
head(data_n_60_trajectory)
## times randomization y_1 y_2 y_3 y_4 information information_lag_1 information_change information_pct_change
## 1 453.1467 56 44 41 36 30 0.04122672 NA NA NA
## 2 466.1324 58 47 42 37 32 0.03642663 0.04122672 -0.004800091 -13.17742
## 3 468.1530 58 47 42 37 34 0.05526950 0.03642663 0.018842867 34.09270
## 4 479.5912 59 48 42 38 36 0.07829199 0.05526950 0.023022490 29.40593
## 5 511.2584 64 52 47 41 38 0.08848096 0.07829199 0.010188968 11.51544
## 6 514.7433 64 52 47 41 40 0.09940316 0.08848096 0.010922199 10.98778
deming::theilsen()
)count_outcomes
monitored_design
estimate_information
initialize_monitored_design()
estimate_information()
information_trajectory()
monitored_analysis()
to conduct interim/final analysesinterim_analysis_1 <-
monitored_analysis(
data = interim_1_data,
monitored_design = monitored_design,
estimation_function = standardization,
estimation_arguments =
list(
estimand = "difference",
y0_formula = y_4 ~ x_1 + x_2 + x_3 + x_4,
y1_formula = y_4 ~ x_1 + x_2 + x_3 + x_4,
family = gaussian,
treatment_column = "tx",
outcome_indicator_column = ".r_4"
)
)
monitored_analysis
is a monitored_design
object
sessionInfo()
: environment, packages, versionsmonitored_design
argument"estimate"
impart
impart
covers planning, monitoring, and analyses