A note on AI tools: You may use AI assistants (ChatGPT, Claude, etc.) to help debug your R code — that’s a realistic professional skill. You may not use AI to generate your interpretations. Every write-up sentence must reflect your own reading of the output. If you use AI for any part of this assignment, note where at the end.
data(UCBAdmissions)UCBAdmissions ships with base R — no upload or URL
needed. It’s a 3-dimensional table: Admit (Admitted/Rejected) × Gender
(Male/Female) × Dept (A–F), from UC Berkeley’s 1973 graduate
admissions.
Step 1 — Inspect the table’s structure.
str(UCBAdmissions)
ftable(UCBAdmissions)Step 2 — Predict before you compute. Before running anything else: if you had to guess, do you think admission rates in 1973 were higher for men, higher for women, or about the same? Write your prediction down.
Step 3 — Collapse across departments and compute overall admission rates.
total <- margin.table(UCBAdmissions, c(1, 2))
total
prop.table(total, 2)Step 4 — Test whether the aggregate association is real.
agg_table <- margin.table(UCBAdmissions, c(2, 1)) # Gender x Admit
chisq.test(agg_table)
library(vcd)
assocstats(agg_table)assocstats(). Effect
sizes are reported regardless of significance — what does this value
tell you about the strength of the aggregate association,
separately from whether it’s significant?Step 5 — Compute admission rates within each department.
apply(UCBAdmissions, 3, function(tab) prop.table(tab, 2)["Admitted", ])Step 6 — Visualize department-level patterns.
library(ggplot2)
ucb_df <- as.data.frame(UCBAdmissions)
ggplot(ucb_df, aes(x = Dept, y = Freq, fill = Admit)) +
geom_col(position = "fill") +
facet_wrap(~ Gender) +
labs(y = "Proportion", x = "Department")Step 7 — Find the lurking variable.
# Applications per department, by gender
margin.table(UCBAdmissions, c(3, 2))The chapter lists four warning signs that a dataset might have a Simpson’s-paradox pattern hiding in it (subgroups differing in size, an implausible aggregate result, a plausible confounding Z, and totals that vary systematically across groups).
Write one paragraph (4–6 sentences) summarizing your findings, as if for a methods section. Include: the aggregate result with its test statistic and Cramér’s V, the department-level pattern, and the correct, non-misleading conclusion about what the 1973 data actually show. Do not claim the university was or wasn’t discriminating — state only what the data support.