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

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/mcnemarExactDP.R

Description

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

Usage

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# 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)

Example output

Loading required package: exactci
Loading required package: ssanv

	Exact McNemar Test (with central confidence intervals)

data:  n=sum(ahr) m=ahr[1, 2] + ahr[2, 1] x=ahr[1, 2]
n = 21, m = 8, x = 1, p-value = 0.07031
alternative hypothesis: true difference in proportions is not equal to 0
95 percent confidence interval:
 -0.54549962  0.02044939
sample estimates:
        x/n     (m-x)/n  difference 
 0.04761905  0.33333333 -0.28571429 


	Exact McNemar test (with central confidence intervals)

data:  ahr
b = 1, c = 7, p-value = 0.07031
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
 0.003169739 1.111975554
sample estimates:
odds ratio 
 0.1428571 

exact2x2 documentation built on Dec. 11, 2021, 9:43 a.m.