## R reference

### Hypothesis testing functions

Function Test Usage Notes
binom.test() Run an exact binomial test binom.test(k, n, null_p Remember to specify the null probability of success as the final argument
chisq.test() Run a $\chi^2$ goodness of fit test chisq.test(<observed counts>, p = <null frequencies>) chisq.test(c(100, 150, 32), p = c(1/3, 1/3, 1/3))
chisq.test() Run a $\chi^2$ contingency table analysis chisq.test(<contingency table>) cont.table <- rbind(c(45,54), c(67,88))

chisq.test(cont.table)
fisher.test() Run Fisher’s exact test fisher.test(<contingency table>) Usage is the same as for contingency chisq.test()

### 2x2 contingency table calculations

• Odds ratio = $\frac{A/C}{B/D} = \frac{A*D}{B*C}$ (or reciprocal)

• Relative risk for Row1 over Row2 = $\frac{A/(R1)}{C/(R2)}$