Skip to content
StatsOtter A workspace for causal thinking
Method library WORKFLOW / 070
Research workflow/3 steps

Simulation-based inference for any model (clarify)

01
The method workspace

Follow the analysis.

Select a node to explore the method

Method mapInput → 3 steps → output
START WITHInput data
ARRIVE ATResults
Read step 01
Inside the methodReasoning, equations & implementation
Step 1 of 3
01
Estimation

Fit any regression model

The core estimate — where the causal quantity itself is computed.

What happens here

Fit the substantive model — here a logit for the probability of positive earnings with a treatment-by-covariate interaction.

Formula
\hat\theta=\frac1S\sum_{s=1}^{S} g(\tilde\beta_s),\quad \tilde\beta_s\sim\mathcal N(\hat\beta,\widehat{\mathrm{Var}}(\hat\beta))
Reads fromNot specified Feeds into#2
Key code
# Install:  install.packages("clarify")
library(clarify)
fit <- glm(re78 > 0 ~ treat * (age + educ + married),
           data = lalonde, family = binomial)

Reference / docs ↗

Discussion on this step (0)
StatsOtterDiscussion starter · Editorial note

Before using this step, make its assumptions and its output explicit. A useful peer note explains what you would check, what could go wrong, or what would change your interpretation.

Questions to explore
  1. Which assumption matters most here, and what evidence could challenge it?
  2. What would you check before passing this output to the next step?

Peer discussion

  • Bring your experience, a question, or a different perspective.
02
Data contract

Inputs & data

A fitted regression model (lm/glm/…) and the data used to fit it.

Show data format & exampleHide example
re78>0 treat age educ married
1 1 37 11 1
0 0 22 9 0
1 1 30 12 1
0 0 45 14 0
03
Read the evidence

Results & interpretation

1 figure Workflow discussion 0
01FigureSimulated E[Y(0)] vs E[Y(1)] with percentile confidence intervals from 1000 coefficient draws.

Result figure rendered by StatsOtter from the package's documented example — unofficial community showcase; all credit to the original authors.

The estimate

\hat\theta=\frac1S\sum_{s=1}^{S} g(\tilde\beta_s),\quad \tilde\beta_s\sim\mathcal N(\hat\beta,\widehat{\mathrm{Var}}(\hat\beta))

Context & interpretation

⚠️ Unofficial community showcase of clarify (docs). Not affiliated with the authors — all credit to Noah Greifer, Steven Worthington, Stefano Iacus & Gary King; this summarizes public documentation.

What it does. clarify is the modern successor to King, Tomz & Wittenberg's Zelig idea: after you fit any regression, it post-processes the model into substantively meaningful quantities (expected values, average marginal effects, first differences) with uncertainty from parameter simulation instead of the delta method.

How it works. sim() draws many coefficient vectors from the model's sampling distribution; sim_ame() / sim_setx() push each draw through the prediction function and average, giving a simulation distribution for the quantity of interest; summary() reports its mean and percentile interval. This sidesteps fragile delta-method approximations for nonlinear models.

Assumptions. The model is correctly specified and its coefficient sampling distribution is approximately multivariate normal (or you supply a bootstrap).

What you get — Simulation-based point estimates and percentile confidence intervals for predictions and average marginal effects.

Example output

         Estimate 2.5 % 97.5 %
E[Y(0)]    0.7666 0.683  0.847
E[Y(1)]    0.7799 0.677  0.879

Using 1000 simulated values per estimate.

Links: package · paper

Peer notes

Discuss the workflow (0)

  • No comments yet — start the conversation.
IN THE MARGINS

Peer discussion