The companion R package for Imai's textbook Quantitative Social Science, bundling every dataset and chapter vignette for hands-on data-analysis teaching.
Input · what goes in
No user data required—the package supplies the textbook's bundled datasets and chapter vignettes.
Show data format & exampleHide example
| dataset | description | rows |
|---|---|---|
| elections | U.S. election returns | 1000+ |
| afghan | Afghanistan survey | 2754 |
| resume | resume audit experiment | 4870 |
| social | social-pressure experiment | 305866 |
Pipeline · the recipe
↑ Click any step in the diagram to read its logic, code, assumptions & discussion.
Install and load qss
Data preparation — shapes the raw inputs into what the estimator expects.
Install the teaching package from GitHub and load the resume audit-experiment dataset from the Causality chapter.
# Install: remotes::install_github("kosukeimai/qss-package")
# devtools::install_github("kosukeimai/qss-package", build_vignettes = TRUE)
library(qss)
data(resume, package = "qss")
- No comments on this step yet — be the first.
Log in to comment on this step.
Cross-tabulate callbacks by race
A pre-flight check — run this before trusting any estimate downstream.
Tabulate callback (0/1) against the randomly assigned applicant race implied by the name.
race.call.tab <- table(race = resume$race, call = resume$call)
race.call.tab
prop.table(race.call.tab, margin = 1)
- No comments on this step yet — be the first.
Log in to comment on this step.
Difference-in-means in callback rates
The core estimate — where the causal quantity itself is computed.
Compute the callback rate for white-sounding and black-sounding names and take the difference (the average causal effect of race).
callback.rate <- prop.table(race.call.tab, margin = 1)[, 2]
ate <- callback.rate["white"] - callback.rate["black"]
ate
- No comments on this step yet — be the first.
Log in to comment on this step.
Interpret the effect
Reporting — turn the numbers into a figure or table a reader can act on.
White-sounding names receive callbacks at a notably higher rate, evidence of racial discrimination in hiring.
round(callback.rate, 3)
round(ate, 3)
- No comments on this step yet — be the first.
Log in to comment on this step.
Output · what you get
Result figure rendered by StatsOtter from the package's documented example — unofficial community showcase; all credit to the original authors.
Result · the numbers
⚠️ Unofficial community showcase of qss (docs). Not affiliated with the authors — all credit to Kosuke Imai & coauthors; this summarizes public documentation.
What it does: qss is the official companion R package to Kosuke Imai's textbook Quantitative Social Science: An Introduction (Princeton University Press, 2017). It packages all of the book's datasets and reproducible code so students and instructors can follow along chapter by chapter. How it works: the package ships ready-to-load datasets (elections, civil war, social-media, intervention studies, and more) and a set of vignettes—one per chapter (causality, measurement, prediction, probability, uncertainty)—that walk through the analyses using base R. Rather than introducing new estimators, it provides a curated, classroom-tested foundation for learning causal inference, measurement, prediction, and statistical inference through real social-science data. Assumptions: none statistical—it is a pedagogical resource. Installed from GitHub (not CRAN), typically with build_vignettes = TRUE to access the chapter tutorials. It anchors a wider teaching ecosystem, including tidyverse and learnr adaptations of the same material.
What you get — Loadable datasets and per-chapter vignettes reproducing the book's analyses (causality, measurement, prediction, probability, uncertainty).
Example output
call
race 0 1
black 2278 157
white 2200 235
prop.table(race.call.tab, margin = 1)[, 2]
black white
0.06447639 0.09650924
callback.rate["white"] - callback.rate["black"]
white
0.03203285

Discussion (0)
Log in to join the discussion.