diff_diff.RDPlot#
- class diff_diff.RDPlot[source]#
Bases:
objectData-driven RD plot builder (CCT 2015; rdrobust 4.0.0
rdplot()parity).Parameters mirror R’s
rdplot()and keep its defaults - includingkernel="uniform"andp=4, which deliberately differ fromRegressionDiscontinuity’s estimation defaults (triangular, p=1): the global fit is a descriptive overlay, not the local RD estimator.- Parameters:
cutoff (float, default 0.0) – Threshold in the running variable.
p (int, default 4) – Order of the global polynomial fits (R accepts any integer >= 0).
nbins (int or (int, int), optional) – Manual number of bins per side; overrides the data-driven selector. Any positive count is accepted (R permissiveness); note that very large bin counts allocate proportional jump grids and, with covariates, a dense per-side bin-dummy matrix (documented performance seam).
binselect (str, default "esmv") – One of
es, espr, esmv, esmvpr, qs, qspr, qsmv, qsmvpr- partition scheme (evenly/quantile spaced) x target (IMSE-optimal / mimicking variance) x variance estimator (spacings / polynomial regression). The spacings variants assume a continuously distributed OUTCOME (CCT 2015 Theorems 3-4); heavy outcome ties trigger a warning recommending the*prsibling. QS cutpoints follow R:quantiletype-7 interpolation, not the paper’s inf-form empirical inverse (documented deviation-from-paper inherited from rdrobust).scale (float or (float, float), optional) – Multiplies the selected number of bins (undersmoothing knob). A fractional product is resolved with the ceiling of CCT 2015 Equation 2. Deviation from R: rdrobust 4.0.0 crashes on fractional products (vector-indexing accident) and rejects a length-2 scale outright on R >= 4.2 (vectorized-if error); both surfaces work here.
kernel (str, default "uniform") – Weighting for the global polynomial fit within
h.h (float or (float, float), optional) – Window for the global fit; default is each side’s full range.
support ((float, float), optional) – Extended support for bin construction; only WIDENS the observed range (R semantics).
masspoints (str, default "adjust") –
"check"warns when either side has >= 20% duplicate running values;"adjust"additionally switches a spacingsbinselectto its polynomial-regression sibling;"off"disables detection.ci (float, optional) – Confidence level (percent) for the per-bin intervals drawn by
RDPlotResult.plot(). CI columns are ALWAYS computed (at 95 whenciis None, matching R);cionly sets the level and turns the error bars on.covs_drop (bool, default True) – Drop redundant covariates (R’s pipeline: stable name-length sort + LINPACK-style QR check) with a warning naming the dropped columns;
Falseraises a deterministic error on collinear covariates.
Methods
__init__([cutoff, p, nbins, binselect, ...])fit(data, outcome_col, running_col[, covariates])Build the RD plot quantities.
get_params()Get parameters of this plot builder.
set_params(**params)Set parameters (transactional: validates the full candidate configuration before mutating this instance).
- __init__(cutoff=0.0, p=4, nbins=None, binselect='esmv', scale=None, kernel='uniform', h=None, support=None, masspoints='adjust', ci=None, covs_drop=True)[source]#
- classmethod __new__(*args, **kwargs)#