iv-2sls

Estimate causal parameters with IV/2SLS using excluded instruments and diagnostics.

33|6|Updated Mar 17, 2026
One-click install
npx skills add https://github.com/xjtulyc/awesome-rosetta-skills --skill iv-2sls
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: iv-2sls
Source: https://github.com/xjtulyc/awesome-rosetta-skills/tree/main/skills/07-economics/iv-2sls
Command: npx skills add https://github.com/xjtulyc/awesome-rosetta-skills --skill iv-2sls

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires linearmodels>=5.3.0, statsmodels>=0.14.0, pandas>=2.0.0, numpy>=1.24.0, scipy>=1.10.0, matplotlib>=3.7.0.

What problem does it solve?

This Skill helps you estimate causal effects when a regressor is endogenous, producing consistent parameter estimates via Instrumental Variables (IV) and Two-Stage Least Squares (2SLS).

Core Features & Use Cases

  • Instrumental-variables estimation (2SLS/LIML): Estimate structural parameters using excluded instruments and included exogenous controls.
  • Endogeneity and validity diagnostics: Automatically compute Wu-Hausman endogeneity tests, first-stage weak-instrument checks, and (when over-identified) Sargan-Hansen overidentification tests.
  • Practical econometrics workflow: Provide an end-to-end pipeline that compiles results into a diagnostic summary and supports OLS vs IV comparison for intuition.
  • Use case: Estimate the causal return to schooling when education is endogenous, using proximity-to-college (or a similar relevance-based instrument) while verifying instrument strength and endogeneity.

Quick Start

Use the iv-2sls skill to estimate IV/2SLS by providing y, an endogenous regressor DataFrame, an instruments DataFrame, and optional exogenous controls.

Frequently Asked Questions about iv-2sls

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I estimate causal effects with endogenous regressors using Python?

To estimate causal effects with endogenous regressors, use IV/2SLS estimation with excluded instruments. This Skill applies linearmodels-based IV2SLS/LIML to provide consistent parameter estimates and automatically outputs endogeneity diagnostics.

What diagnostics are included when running a 2SLS endogeneity test?

A 2SLS endogeneity test in this workflow includes Wu-Hausman tests for endogeneity, first-stage weak-instrument checks, and Sargan-Hansen overidentification tests when applicable, compiling these into a diagnostic summary.

How do I use instrumental variables to estimate the return to schooling?

To estimate the return to schooling with instrumental variables, provide your outcome variable, the endogenous education regressor, and an exogenous instrument like proximity-to-college to verify instrument strength and correct for endogeneity.

Does this econometrics workflow support LIML and robust covariance options?

Yes, this econometrics workflow supports LIML and robust covariance options. It leverages linearmodels to compute IV2SLS and LIML estimates, providing flexibility for handling heteroskedasticity in your causal inference models.

What is the difference between OLS and IV estimation when testing for endogeneity?

The difference between OLS and IV estimation is tested via the Wu-Hausman diagnostic. This Skill provides an OLS versus IV comparison to build intuition on whether endogeneity correction is necessary for consistent parameter estimates.