Skip to contents

Zero early weight for weighted logrank tests

Usage

early_zero_weight(x, early_period = 4, fail_rate = NULL)

Arguments

x

A counting_process()-class data frame with a counting process dataset.

early_period

The initial delay period where weights increase; after this, weights are constant at the final weight in the delay period.

fail_rate

A data frame record the failure rate.

Value

A data frame. The column weight contains the weights for the early zero weighted logrank test for the data in x.

References

Xu, Z., Zhen, B., Park, Y., & Zhu, B. (2017). "Designing therapeutic cancer vaccine trials with delayed treatment effect." Statistics in Medicine, 36(4), 592--605.

Examples

library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
library(gsDesign2)

# Example 1: Unstratified
sim_pw_surv(n = 200) |>
  cut_data_by_event(125) |>
  counting_process(arm = "experimental") |>
  early_zero_weight(early_period = 2) |>
  filter(row_number() %in% seq(5, 200, 40))
#>   stratum events n_event_tol        tte n_risk_tol n_risk_trt         s
#> 1     All      1           0  0.2412922        196         99 0.9800000
#> 2     All      1           0  2.9852132        154         77 0.7782867
#> 3     All      1           0  9.2281147        113         63 0.5751022
#> 4     All      1           0 26.4142469          9          7 0.2751487
#>    o_minus_e var_o_minus_e weight
#> 1 -0.5051020     0.2499740      0
#> 2 -0.5000000     0.2500000      1
#> 3 -0.5575221     0.2466912      1
#> 4 -0.7777778     0.1728395      1

# Example 2: Stratified
n <- 500
# Two strata
stratum <- c("Biomarker-positive", "Biomarker-negative")
prevalence_ratio <- c(0.6, 0.4)

# Enrollment rate
enroll_rate <- define_enroll_rate(
  stratum = rep(stratum, each = 2),
  duration = c(2, 10, 2, 10),
  rate = c(c(1, 4) * prevalence_ratio[1], c(1, 4) * prevalence_ratio[2])
)
enroll_rate$rate <- enroll_rate$rate * n / sum(enroll_rate$duration * enroll_rate$rate)

# Failure rate
med_pos <- 10 # Median of the biomarker positive population
med_neg <- 8 # Median of the biomarker negative population
hr_pos <- c(1, 0.7) # Hazard ratio of the biomarker positive population
hr_neg <- c(1, 0.8) # Hazard ratio of the biomarker negative population
fail_rate <- define_fail_rate(
  stratum = rep(stratum, each = 2),
  duration = c(3, 1000, 4, 1000),
  fail_rate = c(log(2) / c(med_pos, med_pos, med_neg, med_neg)),
  hr = c(hr_pos, hr_neg),
  dropout_rate = 0.01
)

# Simulate data
temp <- to_sim_pw_surv(fail_rate) # Convert the failure rate
set.seed(2023)

sim_pw_surv(
  n = n, # Sample size
  # Stratified design with prevalence ratio of 6:4
  stratum = tibble(stratum = stratum, p = prevalence_ratio),
  # Randomization ratio
  block = c("control", "control", "experimental", "experimental"),
  enroll_rate = enroll_rate, # Enrollment rate
  fail_rate = temp$fail_rate, # Failure rate
  dropout_rate = temp$dropout_rate # Dropout rate
) |>
  cut_data_by_event(125) |>
  counting_process(arm = "experimental") |>
  early_zero_weight(early_period = 2, fail_rate = fail_rate) |>
  filter(row_number() %in% seq(5, 200, 40))
#>              stratum events n_event_tol        tte n_risk_tol n_risk_trt
#> 1 Biomarker-negative      1           0  0.5257917        142         74
#> 2 Biomarker-negative      1           0  4.1066618         79         43
#> 3 Biomarker-positive      1           1  1.9657427        153         74
#> 4 Biomarker-positive      1           0 10.7059605         21         10
#>           s  o_minus_e var_o_minus_e  hr duration weight
#> 1 0.9731944 -0.5211268     0.2495537 0.8        4    0.0
#> 2 0.6800393 -0.5443038     0.2480372 0.8        4    0.8
#> 3 0.8822199  0.5163399     0.2497330 0.7        3    0.0
#> 4 0.5265625 -0.4761905     0.2494331 0.7        3    0.7