# twoby2: Analysis of a two by two table In Epi: A Package for Statistical Analysis in Epidemiology

## 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

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

A list with elements:

 `table` The analysed 2 x 2 table augmented with probabilities and confidence intervals. The confidence intervals for the probabilities are computed using the normal approximation to the log-odds. Confidence intervals for the difference of proportions are computed using method 10 from Newcombe, Stat.Med. 1998, 17, pp.873 ff. `measures` A table of Odds-ratios and relative risk with confidence intervals. `p.value` Exact p-value for the null hypothesis of OR=1

## Author(s)

Mark Myatt. Modified by Bendix Carstensen.

## Examples

 ```1 2 3 4``` ```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 ```

### Example output

```Attaching package: 'Epi'

The following object is masked from 'package:base':

merge.data.frame

2 by 2 table analysis:
------------------------------------------------------
Outcome   : No
Comparing : A vs. B

No Yes    P(No) 95% conf. interval
A 18  14   0.5625     0.390   0.7211
B  4  14   0.2222     0.086   0.4647

95% conf. interval
Relative Risk: 2.5312    1.0121   6.3306
Sample Odds Ratio: 4.5000    1.2112  16.7189
Conditional MLE Odds Ratio: 4.3631    1.0585  22.3524
Probability difference: 0.3403    0.0548   0.5447

Exact P-value: 0.0365
Asymptotic P-value: 0.0247
------------------------------------------------------
2 by 2 table analysis:
------------------------------------------------------
Outcome   : Yes
Comparing : A vs. B

Yes No    P(Yes) 95% conf. interval
A  14 18    0.4375    0.2789    0.610
B  14  4    0.7778    0.5353    0.914

95% conf. interval
Relative Risk:  0.5625    0.3537   0.8946
Sample Odds Ratio:  0.2222    0.0598   0.8256
Conditional MLE Odds Ratio:  0.2292    0.0447   0.9448
Probability difference: -0.3403   -0.5447  -0.0548

Exact P-value: 0.0365
Asymptotic P-value: 0.0247
------------------------------------------------------
```

Epi documentation built on Aug. 23, 2018, 9:04 a.m.