Learn R Programming

rbounds (version 2.1)

FisherSens: Rosenbaum Sensitivity Analysis for Fisher's Exact Test

Description

Calculates sensitivity to hidden bias for Fisher's exact test for a two-by-two contingency table, following the method described in Rosenbaum (2002, sec. 4.4).

Usage

FisherSens(totalN, treatedN, totalSuccesses, treatedSuccesses, Gammas)

Arguments

totalN
total number of observations
treatedN
number of treated observations
totalSuccesses
total number of ``successes''
treatedSuccesses
number of successes in treatment group
Gammas
vector of Gammas (bounds on the differential odds of treatment) at which to test the significance of the results

Value

Returns a matrix with three columns and number of rows equal to the length of "Gammas". Each row indicates the upper and lower bounds for the (one-sided) p-value for a given value of Gamma.

References

Paul R. Rosenbaum. Observational Studies. Springer, New York, 2nd edition, 2002, sec. 4.4

See Also

See also data.prep, binarysens, hlsens, Match, mcontrol

Examples

Run this code
## Fisher's Lady Tasting Tea: milk first or tea first?
LadyTastingTea <- matrix(c(4, 0, 0, 4), nrow = 2,
                         dimnames = list(Guess = c("Milk", "Tea"),
                                         Truth = c("Milk", "Tea")))
## Define "Milk" as "treated"/"success"
FisherSens(totalN = sum(LadyTastingTea), 
           treatedN = sum(LadyTastingTea["Milk", ]),
           totalSuccesses = sum(LadyTastingTea[, "Milk"]), 
           treatedSuccesses = sum(LadyTastingTea["Milk", "Milk"]), 
           Gammas = seq(1, 2, .2))
## Interpretation: Rejection of the null hypothesis 
## (that the lady cannot discriminate between milk-first and tea-first) 
## is insensitive to bias as large as Gamma = 2.

Run the code above in your browser using DataLab