Load data

library(vcd)
data("UCBAdmissions")

rearrange dimensions

UCB <- aperm(UCBAdmissions, c(2,1,3))
# marginal table, collapsing over Dept
fourfold(margin.table(UCB, c(1,2)))

3-way table, stratified by Dept

fourfold(UCB, mfrow=c(2,3))

test homogeneity of odds ratios over Dept

woolf_test(UCB)
## 
##  Woolf-test on Homogeneity of Odds Ratios (no 3-Way assoc.)
## 
## data:  UCB
## X-squared = 17.9017, df = 5, p-value = 0.003072

calculate odds ratios

oddsratio(UCBAdmissions, log=FALSE)
##         A         B         C         D         E         F 
## 0.3492120 0.8025007 1.1330596 0.9212838 1.2216312 0.8278727
# plot log odds ratios
plot(oddsratio(UCBAdmissions), xlab="Department", ylab="Log Odds Ratio (Admit|Gender)")