View source: R/generate_crossing_hazards.R
generate_crossing_hazards | R Documentation |
Generate Dataset with crossing hazards
Create an empty assumtions data.frame for generate_crossing_hazards
Calculate hr after crossing the hazard functions
Calculate true summary statistics for scenarios with crossing hazards
generate_crossing_hazards(condition, fixed_objects = NULL)
assumptions_crossing_hazards(print = interactive())
hr_after_crossing_from_PH_effect_size(
design,
target_power_ph = NA_real_,
final_events = NA_real_,
target_alpha = 0.025
)
cen_rate_from_cen_prop_crossing_hazards(design)
true_summary_statistics_crossing_hazards(
Design,
cutoff_stats = NULL,
milestones = NULL,
fixed_objects = NULL
)
condition |
condition row of Design dataset |
fixed_objects |
additional settings, see details |
print |
print code to generate parameter set? |
design |
design data.frame |
target_power_ph |
target power under proportional hazards |
final_events |
target events for inversion of Schönfeld Formula, defaults to |
target_alpha |
target one-sided alpha level for the power calculation |
Design |
Design data.frame for crossing hazards |
cutoff_stats |
(optionally named) cutoff time, see details |
milestones |
(optionally named) vector of times at which milestone survival should be calculated |
Condidtion has to contain the following columns:
n_trt number of paitents in treatment arm
n_ctrl number of patients in control arm
crossing time of crossing of the hazards
hazard_ctrl hazard in the control arm = hazard before onset of treatment effect
hazard_trt_before hazard in the treatment arm before onset of treatment effect
hazard_trt_after hazard in the treatment arm afert onset of treatment effect
If fixed_objects is given and contains an element t_max
, then this is used
as the cutoff for the simulation used internally. If t_max is not given in
this way the 1-(1/10000) quantile of the survival distribution in the control
or treatment arm is used (which ever is larger).
assumptions_crossing_hazards generates a default design data.frame
for use with generate_crossing_hazards If print is TRUE
code to produce
the template is also printed for copying, pasting and editing by the user.
(This is the default when run in an interactive session.)
hr_after_crossing_from_PH_effect_size
calculates the hazard ratio
after crossing of hazards as follows: First, the hazard ratio needed
to archive the desired power under proportional hazards is calculated by
inverting Schönfeld's sample size formula. Second the median survival times
for both arm under this hazard ratio and proportional hazards are
calculated. Finally the hazard rate of the treatment arm after crossing of
hazards is set such that the median survival time is the same as the one
calculated under proportional hazards.
This is a heuristic and to some extent arbitrary approach to calculate hazard ratios that correspond to reasonable and realistic scenarios.
cen_rate_from_cen_prop_crossing_hazards takes the proportion of
censored patients from the column censoring_prop
. This column describes
the proportion of patients who are censored randomly before experiencing an
event, without regard to administrative censoring.
cutoff_stats
are the times used to calculate the statistics like average
hazard ratios and RMST, that are only calculated up to a certain point.
For generate_crossing_hazards: A dataset with the columns t (time) and trt (1=treatment, 0=control), evt (event, currently TRUE for all observations)
For assumptions_crossing_hazards: a design tibble with default values invisibly
For hr_after_crossing_from_PH_effect_size: the design data.frame passed as argument with the additional column hazard_trt.
for cen_rate_from_cen_prop_crossing_hazards: design data.frame with the additional column random_withdrawal
For true_summary_statistics_crossing_hazards: the design data.frame passed as argument with additional columns,
generate_crossing_hazards()
: simulates a dataset with crossing
hazards
assumptions_crossing_hazards()
: generate default assumptions data.frame
hr_after_crossing_from_PH_effect_size()
: Calculate hr after crossing of the hazards from PH effect size
cen_rate_from_cen_prop_crossing_hazards()
: calculate censoring rate from censoring proportion
true_summary_statistics_crossing_hazards()
: calculate true summary statistics for crossing hazards
one_simulation <- merge(
assumptions_crossing_hazards(),
design_fixed_followup(),
by=NULL
) |>
head(1) |>
generate_crossing_hazards()
head(one_simulation)
tail(one_simulation)
Design <- assumptions_crossing_hazards()
Design
my_design <- merge(
assumptions_crossing_hazards(),
design_fixed_followup(),
by=NULL
)
my_design$final_events <- ceiling((my_design$n_trt + my_design$n_ctrl)*0.75)
my_design$hazard_trt <- NA
my_design <- hr_after_crossing_from_PH_effect_size(my_design, target_power_ph=0.9)
my_design
design <- data.frame(
crossing = c(2, 4, 6),
hazard_ctrl = c(0.05, 0.05, 0.05),
hazard_trt_before = c(0.025, 0.025, 0.025),
hazard_trt_after = c(0.1, 0.1, 0.1),
censoring_prop = c(0.1, 0.3, 0.2),
n_trt = c(50, 50, 50),
n_ctrl = c(50, 50, 50),
followup = c(200, 200, 200),
recruitment = c(50, 50, 50)
)
cen_rate_from_cen_prop_crossing_hazards(design)
my_design <- merge(
assumptions_crossing_hazards(),
design_fixed_followup(),
by=NULL
)
my_design$follwup <- 15
my_design <- true_summary_statistics_crossing_hazards(my_design)
my_design
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.