tenFHcorr: Fleming-Harrington Weighted Logrank Tests plus Correlations

View source: R/tenFHcorr.R

tenFHcorrR Documentation

Fleming-Harrington Weighted Logrank Tests plus Correlations

Description

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

Usage

tenFHcorr(
  x = sim_pw_surv(n = 200) %>% cut_data_by_event(100) %>% counting_process(arm =
    "Experimental"),
  rg = 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

rg

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

corr

a logical; if TRUE (default), return correlation matrix; otherwise, return covariance matrix

Value

a tibble with rg 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(tidyr)
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(rg = 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]

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

x %>% tenFHcorr(rg = tibble(rho = c(0, 0),
                            gamma = c(0, 1)),
                corr = FALSE)

# Off-diagonal element should be variance in following
x %>% tenFHcorr(rg = tibble(rho = 0,
                            gamma =.5),
                corr = FALSE)

# compare off diagonal result with wlr()
x %>% wlr(rg = tibble(rho = 0, gamma =.5))


keaven/simtrial documentation built on April 17, 2023, 4:03 a.m.