MaxLRtest: Maximum Weighted Logrank Test

Description Usage Arguments Details Value See Also Examples

View source: R/MaxLRtest.R View source: R/oxy-MaxLRtest.R

Description

MaxLRtest performs the maximum weighted logrank test if multiple weight functions are provided. It is the regular weighted logrank test, if a single weight function is specified,

Usage

1
2
3
4
5
6
7
MaxLRtest(
  dat,
  Wlist,
  base = c("KM"),
  alpha = 0.05,
  alternative = c("two.sided")
)

Arguments

dat

a dataframe or matrix. The first three columns of the data set are survival time, event status indicator and group label. The status indicator, normally 0=alive, 1=dead/event. Other choices are TRUE/FALSE (TRUE=death) or 1/2 (2=death). The group label can be either numeric values like 0=control, 1=treatment or text like C=control, T=treatment.

Wlist

a list with components of weight functions

base

a text must be one of c("KM", "Combined", "N"), Default: c("KM")

alpha

a number indicating type I error rate, Default: 0.05

alternative

a text must be one of c("two.sided", "less", "greater"), indicating the alternative hypothesis, Default: c("two.sided")

Details

MaxLRtest function performs logrank, weighted logrank test such as Fleming-Harrington test and maximum weighted logrank test depending on the type and number of weight functions. Let w(x_t) denote the weight applied at event time point t, where x_t is the base function. There are three options for base. If KM is used, x_t=1-S_t, where S_t is pooled Kaplan-Meier estimate of survival rate at time point t. A FH(1,0) test needs a weight function 1-x_t. If Combined base is selected, x_t=1-S^*_t, where S^*_t=w_1S^1_t+w_0S^0_t, the weighted average of KM estimate of survival rate for treatment (S^1_t) and control group (S^0_t). It is considered more robust in case of unbalanced data. For option N, x_t=1-\frac{Y_t}{N}, where Y_t is the subjects at risk at time t and N is the total number of subjects.The Wilcoxon and tarone test should use this base. The base x_t in all three cases is an increasing function of time t. Function gen.wgt helps to generate the commonly used weight functions.

Let Λ_1 and Λ_0 denote the cumulative hazard for treatment and control group. The alternative of a two-sided test is H_a: Λ_1 \neq Λ_0. The "less" alternative corresponds to H_a: Λ_1 < Λ_0 and the "greater" alternative is H_a: Λ_1 > Λ_0.

A p-value is obtained from a multivariate normal distribution if multiple weights are provided. The function pmvnorm from R package mvtnorm is used. Because the algorithm is slightly seed-dependent,the p-value and critical value is the average of 10 runs.

Value

a list of components including

stat

a numeric value indicating the test statistic. It is logrank or weighted logrank test statistic if one weight function is specified. Otherwise, it gives the maximum weighted logrank test statistic, which takes the maximum of absolute values of all the statistics.

stat.mat

a matrix with the first column showing weighted logrank test statistics and other columns displaying the variance and covariance between statistics

critV

a numeric value indicating the critical value corresponding to the nominal level - alpha

details

a dataframe showing the intermediate variables used in the calculation.

p.value

a numeric value indicating the p-value of the test

See Also

pwr2n.NPH, gen.wgt

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
data(lung)
#Only keep variables for analysis
tmpd <- with(lung, data.frame(time=SurvTime,stat=1-censor,grp=Treatment))
#logrank test
wlr <- gen.wgt(method = "LR")
t1 <- MaxLRtest(tmpd, Wlist = wlr, base = c("KM") )
t1$stat ;t1$p.value


# maxcombo test
wmax <- gen.wgt(method="Maxcombo")
t2 <- MaxLRtest(tmpd, Wlist = wmax, base = c("KM") )
t2$stat ;t2$p.value
#visualize the weight functions
plot(t2)

nphPower documentation built on Dec. 1, 2021, 5:06 p.m.