pub struct DmlData { /* private fields */ }Expand description
Data for a DML model.
y: outcome, lengthnd: one or more treatments, shape(n, k)(continuous or 0/1)x: covariates / confounders, shape(n, p)z: optional instrument, lengthn(forPlivand, binary,Iivm)t: optional 0/1 time-period indicator (for repeated cross-sections,DidCs)
With several treatments each one is estimated in turn, and the other treatments are added to the covariates (as in DoubleML).
Implementations§
Source§impl DmlData
impl DmlData
Sourcepub fn with_treatments(
y: Array1<f64>,
d: Array2<f64>,
x: Array2<f64>,
) -> Result<Self>
pub fn with_treatments( y: Array1<f64>, d: Array2<f64>, x: Array2<f64>, ) -> Result<Self>
Several treatments, one per column of d.
Sourcepub fn with_instrument(self, z: Array1<f64>) -> Result<Self>
pub fn with_instrument(self, z: Array1<f64>) -> Result<Self>
Attach an instrument z (required by Pliv).
Sourcepub fn with_time_indicator(self, t: Array1<f64>) -> Result<Self>
pub fn with_time_indicator(self, t: Array1<f64>) -> Result<Self>
Attach a 0/1 time-period indicator (post-period = 1), required by
DidCs for repeated cross-sections.
Sourcepub fn with_treatment_names<S: Into<String>>(
self,
names: impl IntoIterator<Item = S>,
) -> Result<Self>
pub fn with_treatment_names<S: Into<String>>( self, names: impl IntoIterator<Item = S>, ) -> Result<Self>
Names shown in summaries (default d, or d0, d1, …).
pub fn n_obs(&self) -> usize
pub fn n_features(&self) -> usize
pub fn n_treat(&self) -> usize
pub fn y(&self) -> ArrayView1<'_, f64>
Sourcepub fn d(&self) -> ArrayView2<'_, f64>
pub fn d(&self) -> ArrayView2<'_, f64>
All treatments, shape (n, k).
Sourcepub fn treatment(&self, j: usize) -> ArrayView1<'_, f64>
pub fn treatment(&self, j: usize) -> ArrayView1<'_, f64>
Treatment j.
pub fn x(&self) -> ArrayView2<'_, f64>
pub fn z(&self) -> Option<ArrayView1<'_, f64>>
Sourcepub fn time(&self) -> Option<ArrayView1<'_, f64>>
pub fn time(&self) -> Option<ArrayView1<'_, f64>>
The 0/1 time-period indicator, if attached.
pub fn treatment_names(&self) -> &[String]
Sourcepub fn covariates_for(&self, j: usize) -> Cow<'_, Array2<f64>>
pub fn covariates_for(&self, j: usize) -> Cow<'_, Array2<f64>>
Covariates used when estimating the effect of treatment j: x plus
the other treatment columns. Borrowed when there is only one treatment.
(Cow = “clone on write”: either a borrowed view or an owned matrix.)
Sourcepub fn is_binary_treatment(&self, j: usize) -> bool
pub fn is_binary_treatment(&self, j: usize) -> bool
True when every value of treatment j is exactly 0 or 1.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DmlData
impl RefUnwindSafe for DmlData
impl Send for DmlData
impl Sync for DmlData
impl Unpin for DmlData
impl UnsafeUnpin for DmlData
impl UnwindSafe for DmlData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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