rddensity
Test for RD manipulation by checking density continuity at the cutoff. Uses Cattaneo-Jansson-Ma local polynomial method to return bias-corrected p-value.
Instructions
CJM (2020) density discontinuity test for RD manipulation. Validation: certified evidence with scoped limitations. Known limitations: Certified native reference-parity evidence covers the default rddensity::rddensity unrestricted triangular-kernel selector and test path on the JSS Lee/RD Senate fixture. Manual side-specific bandwidths follow an explicit user-control convention, not a reference-parity guarantee; backend='r' remains available when direct R package execution is required. Assumptions: Cattaneo-Jansson-Ma (2020) local-polynomial density test: under no manipulation the running-variable density is continuous at the cutoff; Density is estimated from the empirical CDF via local polynomial regression with a data-driven CJM bandwidth and bias-corrected inference (no binning); Sufficient mass on both sides of the cutoff within the bandwidth for the polynomial fit of order p. Pre-conditions: Running variable column + cutoff c for the RD density test; Adequate observations on each side of the cutoff within the chosen bandwidth. Failure modes: Too few points on one side of the cutoff for the local polynomial density fit -> Widen the bandwidth h or lower the polynomial order p to...
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| c | No | RD cutoff. | |
| h | No | Bandwidth. A scalar applies the same bandwidth on both sides; a length-2 sequence is interpreted as ``(h_left, h_right)``. | |
| p | No | Polynomial order for density estimation. | |
| x | Yes | Running variable. | |
| 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 |
| backend | No | ``"native"`` uses StatsPAI's Python port of the default ``rddensity`` unrestricted triangular-kernel selector/test path. ``"r"`` delegates to ``rddensity::rddensity`` through ``Rscript`` when the R package is installed, matching the reference package's selector and test statistic. | native |
| 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 | |||