With output from the function counting_process()
.
Usage
fh_weight(
x = counting_process(cut_data_by_event(sim_pw_surv(n = 200), 150), arm =
"experimental"),
rho_gamma = data.frame(rho = c(0, 0, 1, 1), gamma = c(0, 1, 0, 1)),
return_variance = FALSE,
return_corr = FALSE
)
Arguments
- x
A
counting_process()
-class data frame with a counting process dataset.- rho_gamma
A data frame with variables
rho
andgamma
, both greater than equal to zero, to specify one Fleming-Harrington weighted logrank test per row; Default:data.frame(rho = c(0, 0, 1, 1), gamma = c(0, 1, 0, 1))
.- return_variance
A logical flag that, if
TRUE
, adds columns estimated variance for weighted sum of observed minus expected; see details; Default:FALSE
.- return_corr
A logical flag that, if
TRUE
, adds columns estimated correlation for weighted sum of observed minus expected; see details; Default:FALSE
.
Value
A data frame with rho_gamma
as input and the FH test statistic
for the data in x
. (z
, a directional square root of the usual
weighted logrank test); if variance calculations are specified
(for example, to be used for covariances in a combination test),
then this will be returned in the column Var
.
Details
The input value x
produced by counting_process()
produces a
counting process dataset grouped by stratum and sorted within stratum
by increasing times where events occur.
\(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
library(dplyr)
# Example 1
# Use default enrollment and event rates at cut at 100 events
x <- sim_pw_surv(n = 200) |>
cut_data_by_event(100) |>
counting_process(arm = "experimental")
# Compute logrank FH(0, 1)
fh_weight(x, rho_gamma = data.frame(rho = 0, gamma = 1))
#> rho gamma z
#> 1 0 1 -3.332801
fh_weight(x, rho_gamma = data.frame(rho = 0, gamma = 1), return_variance = TRUE)
#> rho gamma z var
#> 1 0 1 -3.332801 2.477853
# Compute the corvariance between FH(0, 0), FH(0, 1) and FH(1, 0)
fh_weight(x, rho_gamma = data.frame(rho = c(0, 0, 1), gamma = c(0, 1, 0)))
#> rho gamma z
#> 1 0 0 -3.744963
#> 2 0 1 -3.332801
#> 3 1 0 -3.561863
fh_weight(x, rho_gamma = data.frame(rho = c(0, 0, 1), gamma = c(0, 1, 0)), return_variance = TRUE)
#> rho gamma z v1 v2 v3
#> 1 0 0 -3.744963 24.195511 6.495887 17.699623
#> 2 0 1 -3.332801 6.495887 2.477853 4.018035
#> 3 1 0 -3.561863 17.699623 4.018035 13.681589
fh_weight(x, rho_gamma = data.frame(rho = c(0, 0, 1), gamma = c(0, 1, 0)), return_corr = TRUE)
#> rho gamma z v1 v2 v3
#> 1 0 0 -3.744963 1.0000000 0.8389447 0.9728108
#> 2 0 1 -3.332801 0.8389447 1.0000000 0.6900931
#> 3 1 0 -3.561863 0.9728108 0.6900931 1.0000000
# Example 2
# Use default enrollment and event rates at cut of 100 events
set.seed(123)
x <- sim_pw_surv(n = 200) |>
cut_data_by_event(100) |>
counting_process(arm = "experimental") |>
fh_weight(rho_gamma = data.frame(rho = c(0, 0), gamma = c(0, 1)), return_corr = TRUE)
# Compute p-value for MaxCombo
library(mvtnorm)
1 - pmvnorm(
lower = rep(min(x$z), nrow(x)),
corr = data.matrix(select(x, -c(rho, gamma, z))),
algorithm = GenzBretz(maxpts = 50000, abseps = 0.00001)
)[1]
#> [1] 0.003336366
# Check that covariance is as expected
x <- sim_pw_surv(n = 200) |>
cut_data_by_event(100) |>
counting_process(arm = "experimental")
x |> fh_weight(
rho_gamma = data.frame(
rho = c(0, 0),
gamma = c(0, 1)
),
return_variance = TRUE
)
#> rho gamma z v1 v2
#> 1 0 0 -0.2790263 24.554559 6.644167
#> 2 0 1 -1.1511132 6.644167 2.552420
# Off-diagonal element should be variance in following
x |> fh_weight(
rho_gamma = data.frame(
rho = 0,
gamma = .5
),
return_variance = TRUE
)
#> rho gamma z var
#> 1 0 0.5 -0.9492403 6.644167
# Compare off diagonal result with fh_weight()
x |> fh_weight(rho_gamma = data.frame(rho = 0, gamma = .5))
#> rho gamma z
#> 1 0 0.5 -0.9492403