Exact Fisher randomization tests and sharp-null confidence intervals for any randomization scheme — the packaged version of the design-based test.
Input · what goes in
Outcome Y, treatment Z, and a declaration of the randomization scheme.
Show data format & exampleHide example
| Y | Z |
|---|---|
| 0.8 | 0 |
| 1.4 | 1 |
| -0.2 | 0 |
| 0.9 | 1 |
Pipeline · the recipe
↑ Click any step in the diagram to read its logic, code, assumptions & discussion.
Declare the randomization
Data preparation — shapes the raw inputs into what the estimator expects.
Describe exactly how treatment was assigned (here complete randomization of 10 of 20 units) with randomizr.
# Install: install.packages("ri2")
library(ri2); library(randomizr)
dat <- data.frame(Y = rnorm(20), Z = c(rep(0,10), rep(1,10)))
decl <- declare_ra(N = 20, m = 10)
- No comments on this step yet — be the first.
Log in to comment on this step.
Conduct randomization inference
Uncertainty quantification — standard errors, intervals, and aggregation.
conduct_ri re-randomizes thousands of times and compares the observed statistic to the exact reference distribution.
ri <- conduct_ri(Y ~ Z, declaration = decl, assignment = "Z",
sharp_hypothesis = 0, data = dat)
summary(ri)
- 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 ri2 (docs). Not affiliated with the authors — all credit to Alexander Coppock (DeclareDesign); this summarizes public documentation.
What it does. ri2 is the maintained, general-purpose implementation of the Fisher randomization test that anchors Peng Ding's design-based program: it computes exact p-values for the sharp null and sharp-null confidence intervals by re-running the actual assignment mechanism.
How it works. You declare how units were randomized with randomizr (declare_ra), then conduct_ri() re-randomizes thousands of times, recomputes the test statistic under each draw, and compares the observed statistic to that exact reference distribution. It handles blocks, clusters, and arbitrary statistics.
Assumptions. A known assignment mechanism and SUTVA; the basic test targets the sharp null of no effect for any unit.
Implements methods Prof. Ding is known for; package authored by Alexander Coppock.
What you get — An exact randomization p-value (and optionally a sharp-null confidence interval) for the estimate.
Example output
term estimate two_tailed_p_value
1 Z -0.214 0.612

Discussion (0)
Log in to join the discussion.