Skip to main content

RdFlex

Struct RdFlex 

Source
pub struct RdFlex { /* private fields */ }
Expand description

RD with flexible covariate adjustment. A fuzzy design (RdFlex::fuzzy) also adjusts the treatment with a classifier.

Implementations§

Source§

impl RdFlex

Source

pub fn sharp(ml_g: impl Regressor + 'static) -> Self

Sharp design: treatment is 1{score ≥ cutoff}. ml_g learns the outcome and must support sample weights.

Source

pub fn fuzzy( ml_g: impl Regressor + 'static, ml_m: impl Classifier + 'static, ) -> Self

Fuzzy design: ml_m (supporting sample weights) learns the treatment.

Source

pub fn from_boxed( ml_g: Box<dyn Regressor>, ml_m: Option<Box<dyn Classifier>>, ) -> Self

ml_m = Some(_) fits a fuzzy design.

Source

pub fn sharp_binary(ml_g: impl Classifier + 'static) -> Self

Sharp design with a binary (0/1) outcome learned by the classifier ml_g (its class-1 probability), as DoubleML with a classifier.

Source

pub fn fuzzy_binary( ml_g: impl Classifier + 'static, ml_m: impl Classifier + 'static, ) -> Self

Fuzzy design with a binary outcome learned by the classifier ml_g.

Source

pub fn from_boxed_binary( ml_g: Box<dyn Classifier>, ml_m: Option<Box<dyn Classifier>>, ) -> Self

Binary outcome with a boxed classifier; ml_m = Some(_) fits a fuzzy design.

Source

pub fn rd_options(self, options: RdOptions) -> Self

Options of the RD estimator (rdrobust’s keyword arguments in DoubleML: polynomial order, kernel, bandwidth selector, variance, …). The initial first-stage bandwidth is always selected with the defaults.

Source

pub fn rd_covariates(self, covs: Array2<f64>) -> Self

Covariates for the RD estimator itself (rdrobust’s covs), one row per observation; the first stage uses the data’s covariates.

Source

pub fn rd_clusters(self, labels: Vec<i64>) -> Self

Cluster labels for cluster-robust RD standard errors (rdrobust’s cluster); the sample splits are not clustered, as in DoubleML.

Source

pub fn cutoff(self, cutoff: f64) -> Self

Source

pub fn h_fs(self, h: f64) -> Self

Initial first-stage bandwidth (default: rdbwselect without covariates).

Source

pub fn first_stage(self, spec: FirstStage) -> Self

Source

pub fn kernel(self, kernel: RdKernel) -> Self

Source

pub fn n_iterations(self, n: usize) -> Self

Rounds of first-stage fitting and bandwidth updating (default 2).

Source

pub fn n_folds(self, n_folds: usize) -> Self

Number of cross-fitting folds (default 5).

Source

pub fn n_rep(self, n_rep: usize) -> Self

Number of independent sample splits (default 1), aggregated by the median.

Source

pub fn seed(self, seed: u64) -> Self

Seed for the sample splits (default 0).

Source

pub fn fit( &self, data: &DmlData, score: ArrayView1<'_, f64>, ) -> Result<RdFlexFit>

Fit with sample splits stratified by the treatment; score is the running variable.

Source

pub fn fit_with_folds( &self, data: &DmlData, score: ArrayView1<'_, f64>, splits: &[Vec<Fold>], ) -> Result<RdFlexFit>

Fit on given sample splits (one Vec<Fold> per repetition).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V