Install any skill in seconds. Free to start, no credit card required.
Get Started Free →brycewang-stanford/causal-inference-guide
Causal inference methods including DiD, IV, RDD, and synthetic control
Passed 15 of 24 test cases with the skill, and 11 of 24 without it.
and 4 more in the full report
4 fixed11 passed either way9 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 4 test cases the skill fixed. Same model, same prompt, with and without the skill.
What specific key name should be included in the return dictionary of a DiD estimation function to report the total number of observations used in fitting the regression model?
| Checked | Without skill | With skill |
|---|---|---|
| Uses n_obs as the return key for total observation count | Missed | Passed |
The instructions your model reads when the skill loads.
A skill for applying quasi-experimental causal inference methods in observational research. Covers difference-in-differences, instrumental variables, regression discontinuity designs, and synthetic control methods with implementation code and diagnostic checks.
import numpy as np
import pandas as pd
import statsmodels.formula.api as smf
def did_estimation(df: pd.DataFrame, outcome: str, treatment: str,
post: str, covariates: list[str] = None) -> dict:
"""
Estimate a difference-in-differences model.
Args:
df: Panel DataFrame
outcome: Name of outcome variable column
treatment: Name of treatment group indicator (0/1)
post: Name of post-treatment period indicator (0/1)
covariates: Optional list of control variable names
"""
# Create interaction term
df = df.copy()
df['did'] = df[treatment] * df[post]
# Build formula
formula = f"{outcome} ~ {treatment} + {post} + did"
if covariates:
formula += ' + ' + ' + '.join(covariates)
model = smf.ols(formula, data=df).fit(cov_type='cluster',
cov_kwds={'groups': df.get('unit_id', df.index)})
return {
'did_estimate': model.params['did'],
'se': model.bse['did'],
test cases passed, vs 11 / 24 without
Published skills whose descriptions closely match this one, with their headline benchmark lift.
More skills from the same source and nearby in the registry, with their headline benchmark lift.