mccrary_test
Detect manipulation of the running variable at the cutoff in regression-discontinuity designs. Use this test to check for sorting around the threshold, indicating potential invalidity of local randomization.
Instructions
McCrary (2008) density test for manipulation of the running variable at the cutoff in regression-discontinuity designs. A significant discontinuity in the density of x at c is direct evidence that units are sorting around the cutoff (e.g. test-taking strategy, income manipulation), invalidating local randomisation. Assumptions: Smooth density of x at c under the null of no manipulation; Local-linear density estimator captures the shape near c. Pre-conditions: x is continuous with mass on both sides of c; no extreme heaping at c (rounded data invalidates the local-linear density estimate). Failure modes: Test rejects (p < alpha) -- manipulation evidence -> Switch to donut-hole RD (sp.rdrobust(donut=delta)) or partial-identification bounds (sp.rdrbounds); Heaped data near c (e.g. integer-rounded scores) -> The density-test statistic is unreliable on heaped data; consider Frandsen (2017) integer-RD adjustment. Alternatives: sp.rddensity, sp.rdrbounds. Typical minimum N: 200.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| c | No | Cutoff value | |
| x | Yes | Running variable | |
| bw | No | Bandwidth; auto if None | |
| alpha | No | Significance level for confidence intervals and tests. | |
| detail | No | Payload depth: 'minimal' (~150 tokens) for sub-step calls where only the point estimate is needed; 'standard' (~1K tokens) for diagnostics + coefficient table; 'agent' (~2K tokens, default) adds violations / next_steps / suggested_functions so the LLM can plan its next call without another round-trip. | agent |
| n_bins | No | Histogram bins; auto if None | |
| as_handle | No | If true, cache the fitted result on the server and return result_id + result_uri alongside the JSON payload so a subsequent tools/call can chain without re-running. | |
| data_path | Yes | Absolute path or URL to a data file. Supported: .csv / .tsv / .txt (delimited), .parquet / .pq, .feather / .arrow, .xlsx / .xls, .dta (Stata), .json / .jsonl. Schemes: file://, s3://, gs://, https://. | |
| result_id | No | Optional handle to a previously-fitted result (returned by an earlier call when as_handle=true). Tools that operate on a fitted object accept this in place of re-supplying data_path + columns. | |
| data_columns | No | Optional column projection. Parquet/Feather/Stata loaders honour this for fast partial reads. | |
| data_sample_n | No | Optional uniform random subsample size (seed=0, deterministic) — useful on huge panels. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||