Weighted logrank test
Usage
wlr(data, weight, return_variance = FALSE, ratio = NULL)
# S3 method for class 'tte_data'
wlr(data, weight, return_variance = FALSE, ratio = NULL)
# S3 method for class 'counting_process'
wlr(data, weight, return_variance = FALSE, ratio = NULL)
Arguments
- data
Dataset (generated by
sim_pw_surv()
) that has been cut bycounting_process()
,cut_data_by_date()
, orcut_data_by_event()
.- weight
Weighting functions, such as
fh()
,mb()
, andearly_zero()
.- return_variance
A logical flag that, if
TRUE
, adds columns estimated variance for weighted sum of observed minus expected; see details; Default:FALSE
.- ratio
randomization ratio (experimental:control).
If the
data
is generated by simtrial, such asdata = sim_pw_surv(...) |> cut_data_by_date(...)
data = sim_pw_surv(...) |> cut_data_by_event(...)
data = sim_pw_surv(...) |> cut_data_by_date(...) |> counting_process(...)
data = sim_pw_surv(...) |> cut_data_by_event(...) |> counting_process(...)
there is no need to input theratio
, as simtrial gets theratio
via theblock
arguments insim_pw_surv()
.
If the
data
is a custom dataset (see Example 2) below,Users are suggested to input the planned randomization ratio to
ratio
;If not, simtrial takes the empirical randomization ratio.
Value
A list containing the test method (method
),
parameters of this test method (parameter
),
point estimate of the treatment effect (estimate
),
standardized error of the treatment effect (se
),
Z-score (z
), p-values (p_value
).
Details
\(z\) - Standardized normal Fleming-Harrington weighted logrank test.
\(i\) - Stratum index.
\(d_i\) - Number of distinct times at which events occurred in stratum \(i\).
\(t_{ij}\) - Ordered times at which events in stratum \(i\), \(j = 1, 2, \ldots, d_i\) were observed; for each observation, \(t_{ij}\) represents the time post study entry.
\(O_{ij.}\) - Total number of events in stratum \(i\) that occurred at time \(t_{ij}\).
\(O_{ije}\) - Total number of events in stratum \(i\) in the experimental treatment group that occurred at time \(t_{ij}\).
\(N_{ij.}\) - Total number of study subjects in stratum \(i\) who were followed for at least duration.
\(E_{ije}\) - Expected observations in experimental treatment group given random selection of \(O_{ij.}\) from those in stratum \(i\) at risk at time \(t_{ij}\).
\(V_{ije}\) - Hypergeometric variance for \(E_{ije}\) as produced in
Var
fromcounting_process()
.\(N_{ije}\) - Total number of study subjects in stratum \(i\) in the experimental treatment group who were followed for at least duration \(t_{ij}\).
\(E_{ije}\) - Expected observations in experimental group in stratum \(i\) at time \(t_{ij}\) conditioning on the overall number of events and at risk populations at that time and sampling at risk observations without replacement: $$E_{ije} = O_{ij.} N_{ije}/N_{ij.}$$
\(S_{ij}\) - Kaplan-Meier estimate of survival in combined treatment groups immediately prior to time \(t_{ij}\).
\(\rho, \gamma\) - Real parameters for Fleming-Harrington test.
\(X_i\) - Numerator for signed logrank test in stratum \(i\) $$X_i = \sum_{j=1}^{d_{i}} S_{ij}^\rho(1-S_{ij}^\gamma)(O_{ije}-E_{ije})$$
\(V_{ij}\) - Variance used in denominator for Fleming-Harrington weighted logrank tests $$V_i = \sum_{j=1}^{d_{i}} (S_{ij}^\rho(1-S_{ij}^\gamma))^2V_{ij})$$ The stratified Fleming-Harrington weighted logrank test is then computed as: $$z = \sum_i X_i/\sqrt{\sum_i V_i}.$$
Examples
# ---------------------- #
# Example 1 #
# Use dataset generated #
# by simtrial #
# ---------------------- #
x <- sim_pw_surv(n = 200) |> cut_data_by_event(100)
# Example 1A: WLR test with FH wights
x |> wlr(weight = fh(rho = 0, gamma = 0.5))
#> $method
#> [1] "WLR"
#>
#> $parameter
#> [1] "FH(rho=0, gamma=0.5)"
#>
#> $estimate
#> [1] -10.39261
#>
#> $se
#> [1] 2.578534
#>
#> $z
#> [1] 4.030433
#>
#> $info
#> [1] 6.706301
#>
#> $info0
#> [1] 7.185266
#>
x |> wlr(weight = fh(rho = 0, gamma = 0.5), return_variance = TRUE)
#> $method
#> [1] "WLR"
#>
#> $parameter
#> [1] "FH(rho=0, gamma=0.5)"
#>
#> $estimate
#> [1] -10.39261
#>
#> $se
#> [1] 2.578534
#>
#> $z
#> [1] 4.030433
#>
#> $info
#> [1] 6.706301
#>
#> $info0
#> [1] 7.185266
#>
# Example 1B: WLR test with MB wights
x |> wlr(weight = mb(delay = 4, w_max = 2))
#> $method
#> [1] "WLR"
#>
#> $parameter
#> [1] "MB(delay = 4, max_weight = 2)"
#>
#> $estimate
#> [1] -22.64058
#>
#> $se
#> [1] 6.064475
#>
#> $z
#> [1] 3.733313
#>
#> $info
#> [1] 35.70777
#>
#> $info0
#> [1] 38.37037
#>
# Example 1C: WLR test with early zero wights
x |> wlr(weight = early_zero(early_period = 4))
#> $method
#> [1] "WLR"
#>
#> $parameter
#> [1] "Xu 2017 with first 4 months of 0 weights"
#>
#> $estimate
#> [1] -16.83342
#>
#> $se
#> [1] 3.511878
#>
#> $z
#> [1] 4.793281
#>
#> $info
#> [1] 10.75472
#>
#> $info0
#> [1] 13.25
#>
# Example 1D
# For increased computational speed when running many WLR tests, you can
# pre-compute the counting_process() step first, and then pass the result of
# counting_process() directly to wlr()
x <- x |> counting_process(arm = "experimental")
x |> wlr(weight = fh(rho = 0, gamma = 1))
#> $method
#> [1] "WLR"
#>
#> $parameter
#> [1] "FH(rho=0, gamma=1)"
#>
#> $estimate
#> [1] -6.606821
#>
#> $se
#> [1] 1.631434
#>
#> $z
#> [1] 4.049702
#>
#> $info
#> [1] 2.854797
#>
#> $info0
#> [1] 2.982862
#>
x |> wlr(weight = mb(delay = 4, w_max = 2))
#> $method
#> [1] "WLR"
#>
#> $parameter
#> [1] "MB(delay = 4, max_weight = 2)"
#>
#> $estimate
#> [1] -22.64058
#>
#> $se
#> [1] 6.064475
#>
#> $z
#> [1] 3.733313
#>
#> $info
#> [1] 35.70777
#>
#> $info0
#> [1] 38.37037
#>
x |> wlr(weight = early_zero(early_period = 4))
#> $method
#> [1] "WLR"
#>
#> $parameter
#> [1] "Xu 2017 with first 4 months of 0 weights"
#>
#> $estimate
#> [1] -16.83342
#>
#> $se
#> [1] 3.511878
#>
#> $z
#> [1] 4.793281
#>
#> $info
#> [1] 10.75472
#>
#> $info0
#> [1] 13.25
#>
# ---------------------- #
# Example 2 #
# Use cumsum dataset #
# ---------------------- #
x <- data.frame(treatment = ifelse(ex1_delayed_effect$trt == 1, "experimental", "control"),
stratum = rep("All", nrow(ex1_delayed_effect)),
tte = ex1_delayed_effect$month,
event = ex1_delayed_effect$evntd)
class(x) <- c("tte_data", class(x))
# Users can specify the randomization ratio to calculate the statistical information under H0
x |> wlr(weight = fh(rho = 0, gamma = 0.5), ratio = 2)
#> $method
#> [1] "WLR"
#>
#> $parameter
#> [1] "FH(rho=0, gamma=0.5)"
#>
#> $estimate
#> [1] -12.28665
#>
#> $se
#> [1] 3.716574
#>
#> $z
#> [1] 3.305908
#>
#> $info
#> [1] 16.60727
#>
#> $info0
#> [1] 15.27192
#>
x |>
counting_process(arm = "experimental") |>
wlr(weight = fh(rho = 0, gamma = 0.5), ratio = 2)
#> $method
#> [1] "WLR"
#>
#> $parameter
#> [1] "FH(rho=0, gamma=0.5)"
#>
#> $estimate
#> [1] -12.28665
#>
#> $se
#> [1] 3.716574
#>
#> $z
#> [1] 3.305908
#>
#> $info
#> [1] 16.60727
#>
#> $info0
#> [1] 15.27192
#>
# If users don't provide the randomization ratio, we will calculate the emperical ratio
x |> wlr(weight = fh(rho = 0, gamma = 0.5))
#> $method
#> [1] "WLR"
#>
#> $parameter
#> [1] "FH(rho=0, gamma=0.5)"
#>
#> $estimate
#> [1] -12.28665
#>
#> $se
#> [1] 3.716574
#>
#> $z
#> [1] 3.305908
#>
#> $info
#> [1] 16.60727
#>
#> $info0
#> [1] 15.31399
#>
x |>
counting_process(arm = "experimental") |>
wlr(weight = fh(rho = 0, gamma = 0.5))
#> $method
#> [1] "WLR"
#>
#> $parameter
#> [1] "FH(rho=0, gamma=0.5)"
#>
#> $estimate
#> [1] -12.28665
#>
#> $se
#> [1] 3.716574
#>
#> $z
#> [1] 3.305908
#>
#> $info
#> [1] 16.60727
#>
#> $info0
#> [1] 15.31399
#>