exactLR: exactLR

Description Usage Arguments Details Value Examples

View source: R/permLR.R

Description

One-sided exact / approximate permutation and asymptotic log-rank test

Usage

1
exactLR(B, formula, data = parent.frame(), type = "exact")

Arguments

B

number of random permutations (only used if type="approximate")

formula

a formula object, as used by coxph, left hand side must be a 'Surv' object, right hand side may only consist of a single term (treatment indicator)

data

data.frame or list containing the variables in "formula", by default "formula" is evaluated in the parent frame

type

if type="exact" performs complete enumeration of all permutations, if type="approximate" draw random permutations, if type="asymptotic" perform asymptotic log-rank test

Details

This function performs a standard exact or approximate permutation test which is only valid under the extended null hypothesis of equal survival AND censoring distributions.

Value

A list containing the exact or approximate permutation p-value and the observed test statistic

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
T <- rexp(20)
C <- rexp(20)
data <- data.frame(time=pmin(T, C), status=(T<=C), trt=rbinom(20, 1, 0.5))

# Approximate permutation test using 1000 random permutations
x <- exactLR(1000, Surv(time, status) ~ trt, data, "approximate")

print(paste("Approximate permutation p-value:", x$p))

# Exact permutation test
y <- exactLR(0, Surv(time, status) ~ trt, data, "exact")
print(paste("Exact permutation p-value:", y$p))

permGS documentation built on May 2, 2019, 9:16 a.m.