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

Instrumental variables & 2SLS for an endogenous treatment (ivreg)

Source ivreg — Fox, Kleiber & Zeileis
01
The method workspace

Follow the analysis.

Select a node to explore the method

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

Outcome, endogenous treatment, instrument

Data preparation — shapes the raw inputs into what the estimator expects.

What happens here

Assemble Y, D, Z, X. The instrument must affect D and only affect Y through D.

Formula
\tau_{\mathrm{LATE}}=\dfrac{\mathrm{Cov}(Y,Z)}{\mathrm{Cov}(D,Z)}
Reads fromNot specified Feeds intoNot specified
Key code
library(ivreg)
# y ~ d + x | z + x   (endogenous d, instrument z)

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

Outcome Y, an endogenous treatment D, an instrument Z (relevant + excludable), and covariates X.

Show data format & exampleHide example

Format — one row per unit: y, d (endogenous), z (instrument), covariates x.

  y     d   z    x1
 3.1    1   1   0.4
 1.8    0   0  -0.1
 2.4    0   1   1.2
03
Read the evidence

Results & interpretation

Workflow discussion 0
Context & interpretation

⚠️ Unofficial community showcase of ivreg. Not affiliated with the authors; all credit to them.

When treatment is endogenous, an instrument identifies the complier (LATE) effect via two-stage least squares — after you check the instrument is strong.

Peer notes

Discuss the workflow (0)

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

Peer discussion