1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//! Pure-Rust numerical core for robust local-polynomial regression-discontinuity
//! (RD) estimation: a faithful port of the Calonico-Cattaneo-Farrell-Titiunik
//! `rdrobust` package (R source `R/rdrobust/R/{functions,rdrobust,rdbwselect,rdplot}.R`).
//!
//! # What it computes
//!
//! - [`rdrobust()`]: the sharp or fuzzy RD point estimate, with conventional and
//! bias-corrected coefficients, CCT robust variance, z-statistics, p-values, and
//! confidence intervals.
//! - [`rdbwselect`]: MSE- and CER-optimal bandwidth selection (all ten selectors).
//! - [`rdplot()`]: the binned-scatter quantities and the global polynomial curve.
//! - [`rdrobust_batch`] and [`rdrobust_multi_cutoff`]: rayon-parallel fan-out over
//! independent fits for Monte-Carlo and many-cutoff workloads.
//!
//! Outputs match the R reference to ~1e-8 on continuous quantities and ~1e-11 on
//! clustered variances, and exactly on discrete decisions (neighbor sets,
//! mass-point grouping, bin counts).
//!
//! # Example
//!
//! ```
//! use rdrobust_core::{rdrobust_batch, Dataset, RdRobustOptions};
//!
//! // A small sharp RD: the outcome jumps by about 2 at the cutoff c = 0.
//! let x: Vec<f64> = (0..200).map(|i| -1.0 + 2.0 * (i as f64 + 0.5) / 200.0).collect();
//! let y: Vec<f64> = x
//! .iter()
//! .enumerate()
//! .map(|(i, &xi)| 0.5 * xi + if xi >= 0.0 { 2.0 } else { 0.0 } + 0.3 * (i as f64).sin())
//! .collect();
//!
//! let opts = RdRobustOptions::default(); // R defaults: p=1, q=2, triangular kernel, nn variance
//! let ds = Dataset { y: &y, x: &x, t: None, z: None, dz: 0, cluster: None, weights: None };
//! let out = rdrobust_batch(&[ds], &opts);
//!
//! // Each result's rows are [Conventional, Bias-Corrected, Robust].
//! assert_eq!(out.len(), 1);
//! assert!(out[0].coef[0].is_finite());
//! assert!(out[0].se[2] >= 0.0);
//! ```
//!
//! # Scope and limitations
//!
//! The main output set (`coef`/`se`/`z`/`pv`/`ci`/`bws`) is complete. Per-side
//! decompositions, fuzzy first-stage diagnostics, and the `rdplot` QS / covariate /
//! CI extensions are not ported. The raw [`rdrobust`]/[`rdrobust_with`] entry points
//! still return `NaN` on degenerate inputs (a cutoff outside the support, a fuzzy
//! treatment with no first stage); [`try_rdrobust_with`] adds a typed validation
//! channel ([`RdError`]) that rejects those inputs up front. See `CHANGELOG.md`
//! for the full list.
pub
pub
pub
pub
pub
pub
pub
pub use ;
pub use ;
pub use ;
pub use kweight;
pub use ;
pub use ;
/// Local-polynomial weighting kernel (mirrors `rdrobust_kweight`).
/// Variance-covariance estimator (mirrors the `vce` argument).