mcnemarExactDP: Exact McNemar (Paired Binary) Test with Difference in...

View source: R/mcnemarExactDP.R

mcnemarExactDPR Documentation

Exact McNemar (Paired Binary) Test with Difference in Proportions

Description

Gives a valid (i.e., exact) test of paired binary responses, with compatible confidence intervals on the difference in proportions.

Usage

mcnemarExactDP(x, m, n, nullparm = 0, alternative = c("two.sided", "less", "greater"), 
    conf.level = 0.95, nmc = 0)

Arguments

m

number of pairs with mismatched responses

x

number of pairs with response of 1 for treatment and 0 for control

n

total number of pairs

nullparm

null parameter value for the difference in proportions: proportion with events on treatment minus proportion with events on control

alternative

alternative hypothesis, must be one of "two.sided", "greater" or "less"

conf.level

confidence level for the returned confidence interval

nmc

number of Monte Carlo replications, nmc=0 (default) uses numeric integration instead

Details

For paired binary responses, a simple test is McNemars test, which conditions on the number of discordant pairs. The mcnemar.exact function gives results in terms of odds ratios. This function gives results in terms of the difference in proportions. The p-values will be identical between the two functions, but the estimates and confidence intervals will be different.

For this function, we use the melding idea (Fay, et al, 2015), to create compatable confidence intervals with exact versions of McNemars test. For details see Fay and Lumbard (2021). See Fagerland, et al (2013) for other parameters and methods related to paired binary responses. The advantage of this version is that it is exact, and faster than the unconditional exact methods (which may be more powerful).

Value

A list with class "htest" containing the following components:

p.value

the p-value of the test

conf.int

a confidence interval for the difference in proportions

estimate

sample proportions and their difference

null.value

difference in proportions under the null

alternative

a character string describing the alternative hypothesis

method

a character string describing the test

data.name

a character string giving the names of the data

Author(s)

Michael P. Fay, Keith Lumbard

References

Fay, MP, Proschan, MA, and Brittain, E (2015). Combining one-sample confidence procedures for inference in the two-sample case. Biometrics,71(1),146-156.

Fay MP, and Lumbard, K (2021). Confidence Intervals for Difference in Proportions for Matched Pairs Compatible with Exact McNemars or Sign Tests. Statistics in Medicine, 40(5): 1147-1159.

Fagerland, Lydersen and Laake (2013), Recommended tests and confidence intervals for paired binomial proportions. Statitics in Medicine, 33:2850-2875.

See Also

See mcnemar.exact or exact2x2 with paired=TRUE for confidence intervals on the odds ratio.

Examples

# For test on contingency table of the pairs
# From Bentur, et al (2009) Pediatric Pulmonology 44:845-850.
# see also Table II of Fagerland, Lydersen and Laake 
# (2013, Stat in Med, 33: 2850-2875)
# 
#                 After SCT
#                 AHR       No AHR
#              ----------------- 
# Before SCT  |    
#         AHR |    1         1 
#      No AHR |    7        12
#              -----------------

ahr<-matrix(c(1,7,1,12),2,2,
            dimnames=list(paste("Before SCT,",c("AHR","No AHR")),
                          paste("After SCT,",c("AHR","No AHR"))))
mcnemarExactDP(n=sum(ahr),m=ahr[1,2]+ahr[2,1], x=ahr[1,2])
# compare to mcnemar.exact
# same p-value, but mcnemar.exact gives conf int on odds ratio 
mcnemar.exact(ahr)

exact2x2 documentation built on Feb. 16, 2023, 10:11 p.m.