Skip to contents

Correlations can be used with mvtnorm::pmvnorm() to compute p-value for MaxCombo, the maximum of the specified Fleming-Harrington tests.

Usage

tenFHcorr(
  x = sim_pw_surv(n = 200) %>% cut_data_by_event(100) %>% counting_process(arm =
    "experimental"),
  rho_gamma = tibble(rho = c(0, 0, 1, 1), gamma = c(0, 1, 0, 1)),
  corr = TRUE
)

Arguments

x

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

rho_gamma

A tibble with variables rho and gamma, both greater than equal to zero, to specify one Fleming-Harrington weighted logrank test per row.

corr

Logical; if TRUE (default), return correlation matrix; otherwise, return covariance matrix.

Value

A tibble with rho_gamma as input, the FH test statistics specified for the data in z, and the correlation or covariance matrix for these tests in variables starting with v.

Examples

library(tibble)
library(dplyr)

# Use default enrollment and event rates at cut of 100 events
x <- sim_pw_surv(n = 200) %>%
  cut_data_by_event(100) %>%
  counting_process(arm = "experimental")

# Compute logrank (FH(0,0)) and FH(0,1)
x <- x %>% tenFHcorr(rho_gamma = tibble(
  rho = c(0, 0),
  gamma = c(0, 1)
))

# 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.0003948811

# Check that covariance is as expected
x <- sim_pw_surv(n = 200) %>%
  cut_data_by_event(100) %>%
  counting_process(arm = "experimental")

x %>% tenFHcorr(
  rho_gamma = tibble(
    rho = c(0, 0),
    gamma = c(0, 1)
  ),
  corr = FALSE
)
#>   rho gamma         z        v1       v2
#> 1   0     0 -1.564440 24.746736 6.565217
#> 2   0     1 -2.596943  6.565217 2.465438

# Off-diagonal element should be variance in following
x %>% tenFHcorr(
  rho_gamma = tibble(
    rho = 0,
    gamma = .5
  ),
  corr = FALSE
)
#>   rho gamma         z       v1
#> 1   0   0.5 -2.196415 6.565217

# Compare off diagonal result with wlr()
x %>% wlr(rho_gamma = tibble(rho = 0, gamma = .5))
#> # A tibble: 1 × 3
#>     rho gamma     z
#>   <dbl> <dbl> <dbl>
#> 1     0   0.5 -2.20