Learn R Programming

Epi (version 2.7)

twoby2: Analysis of a two by two table

Description

Computes the usual measures of association in a 2 by 2 table with confidence intervals. Also produces asymtotic and exact tests. Assumes that comparison of probability of the first column level between levels of the row variable is of interest. Output requires that the input matrix has meaningful row and column labels.

Usage

twoby2(exposure, outcome, alpha = 0.05, print = TRUE, dec = 4, conf.level = 1-alpha, F.lim = 10000)

Arguments

exposure
If a table the analysis is based on the first two rows and first two columns of this. If a variable, this variable is tabulated against
outcome
as the second variable
alpha
Significance level
print
Should the results be printed?
dec
Number of decimals in the printout.
conf.level
1-alpha
F.lim
If the table total exceeds F.lim, Fisher's exact test is not computed

Value

Examples

Run this code
Treat <- sample(c("A","B"), 50, rep=TRUE )
Resp <- c("Yes","No")[1+rbinom(50,1,0.3+0.2*(Treat=="A"))]
twoby2( Treat, Resp )                 
twoby2( table( Treat, Resp )[,2:1] ) # Comparison the other way round

Run the code above in your browser using DataLab