This function estimates the sample MCF difference between two groups. Both the point estimates and the confidence intervals are computed (Lawless and Nadeau 1995). The two-sample pseudo-score test proposed by Cook, Lawless, and Nadeau (1996) is also performed by default.

mcfDiff(mcf1, mcf2 = NULL, level = 0.95, ...)

mcfDiff.test(
mcf1,
mcf2 = NULL,
testVariance = c("robust", "Poisson", "none"),
...
)

## Arguments

mcf1 A mcf.formula object representing the MCF for one or two groups. An optional second mcf.formula object or NULL. A numeric value indicating the confidence level required. The default value is 0.95. Other arguments passed to mcfDiff.test. A character string specifying the method for computing the variance estimate for the pseudo-score test statistic proposed by Cook, Lawless, and Nadeau (1996). The applicable options include "robust" (default) for an estimate robust to departures from Poisson assumptions, "Poisson" for an estimate for Poisson process, and "none" for not performing any test (if only the difference estimates are of interest in mcfDiff).

## Value

The function mcfDiff returns a mcfDiff object (of S4 class) that contains the following slots:

• call: Function call.

• MCF: Estimated Mean cumulative function Difference at each time point.

• origin: Time origins of the two groups.

• variance: The method used for variance estimates.

• logConfInt: A logical value indicating whether normality is assumed for log(MCF) instead of MCF itself. For mcfDiff object, it is always FALSE.

• level: Confidence level specified.

• test: A mcfDiff.test object for the hypothesis test results.

The function mcfDiff.test returns a mcfDiff.test object (of S4 class) that contains the following slots:

• .Data: A numeric matrix (of two rows and five columns) for hypothesis testing results.

• testVariance: A character string (or vector of length one) indicating the method used for the variance estimates of the test statistic.

## Details

The function mcfDiff estimates the two-sample MCFs' difference and internally calls function mcfDiff.test to perform the pseudo-score tests by default. A - method is available as a simple wrapper for the function mcfDiff for comparing two-sample MCFs from two mcf.formula objects. For instance, suppose mcf1 and mcf2 are mcf.formula objects, each of which represents the sample MCF estimates for one group. The function call mcf1 - mcf2 is equivalent to mcfDiff(mcf1, mcf2).

The null hypothesis of the two-sample pseudo-score test is that there is no difference between the two sample MCFs, while the alternative hypothesis suggests a difference. The test is based on a family of test statistics proposed by Lawless and Nadeau (1995). The argument testVariance specifies the method for computing the variance estimates of the test statistics under different model assumption. See the document of argument testVariance for all applicable options. For the variance estimates robust to departures from Poisson process assumption, both constant weight and the linear weight function (with scaling) suggested in Cook, Lawless, and Nadeau (1996) are implemented. The constant weight is powerful in cases where the two MCFs are approximately proportional to each other. The linear weight function is originally a(u) = t - u, where u represents the time variable and t is the first time point when the risk set of either group becomes empty. It is further scaled by 1 / t for test statistics invariant to the unit of measurement of the time variable. The linear weight function puts more emphasis on the difference at earily times than later times and is more powerful for cases where the MCFs are no longer proportional to each other, but not crossing. Also see Cook and Lawless (2007, Section 3.7.5) for more details.

## References

Lawless, J. F., & Nadeau, C. (1995). Some Simple Robust Methods for the Analysis of Recurrent Events. Technometrics, 37(2), 158--168.

Cook, R. J., Lawless, J. F., & Nadeau, C. (1996). Robust Tests for Treatment Comparisons Based on Recurrent Event Responses. Biometrics, 52(2), 557--571.

Cook, R. J., & Lawless, J. (2007). The Statistical Analysis of Recurrent Events. Springer Science & Business Media.

## Examples

## See examples given for function mcf.