Skip to main content

DmlFit

Struct DmlFit 

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

A fitted DML model: estimates, standard errors and the per-repetition scores and nuisance predictions behind them.

Arrays indexed by treatment have length k = n_treat; per-repetition arrays have shape (k, n_rep).

Implementations§

Source§

impl DmlFit

Source

pub fn bootstrap( &self, method: BootstrapMethod, n_boot: usize, seed: u64, ) -> Result<Bootstrap>

Multiplier bootstrap with n_boot draws per repetition: t*_b = Σ_i ξ_bi · ψ_i / (J · n · se).

Source

pub fn bootstrap_with_weights( &self, weights: &[Array2<f64>], ) -> Result<Bootstrap>

Bootstrap with caller-supplied weights, one (n_boot, n) matrix per repetition (e.g. to reproduce DoubleML’s draws exactly).

Source§

impl DmlFit

Source

pub fn model_name(&self) -> &str

Source

pub fn treatment_names(&self) -> &[String]

Source

pub fn n_obs(&self) -> usize

Source

pub fn n_treat(&self) -> usize

Source

pub fn n_rep(&self) -> usize

Source

pub fn n_folds(&self) -> usize

Source

pub fn n_clusters(&self) -> Option<usize>

Number of clusters (two-way: the smaller dimension) for a clustered fit, None otherwise.

Source

pub fn coef(&self) -> ArrayView1<'_, f64>

Point estimates θ̂ (median over repetitions).

Source

pub fn se(&self) -> ArrayView1<'_, f64>

Standard errors (aggregated over repetitions).

Source

pub fn t_stat(&self) -> Array1<f64>

Source

pub fn p_value(&self) -> Array1<f64>

Two-sided p-values for H0: θ = 0 from the aggregated t-statistic, as DoubleML’s pval. (Multiple-testing adjustments in p_adjust instead take the median over repetitions.)

Source

pub fn confint(&self, level: f64) -> Result<Array2<f64>>

Pointwise Wald confidence intervals at level, shape (k, 2) (median over repetitions of each repetition’s interval).

Source

pub fn p_adjust(&self, method: PAdjust) -> Array1<f64>

Multiple-testing adjusted p-values across treatments (applied per repetition, then the median is taken). For the bootstrap-based Romano–Wolf procedure see Bootstrap::romano_wolf.

Source

pub fn all_coef(&self) -> ArrayView2<'_, f64>

Estimates for every repetition, shape (k, n_rep).

Source

pub fn all_se(&self) -> ArrayView2<'_, f64>

Source

pub fn psi(&self) -> ArrayView3<'_, f64>

Score values ψ at θ̂, shape (n, k, n_rep).

Source

pub fn psi_elements(&self) -> (ArrayView3<'_, f64>, ArrayView3<'_, f64>)

Score elements ψ_a and ψ_b (ψ = ψ_a·θ + ψ_b), shape (n, k, n_rep).

Source

pub fn cate(&self, basis: ArrayView2<'_, f64>) -> Result<Blp>

Best linear predictor of the CATE on basis (shape (n, p), include a constant column for an intercept), with HC0 inference (Semenova and Chernozhukov, 2021), as DoubleML’s cate. Available for a single treatment of Plr (outcome residual on the basis scaled by the treatment residual), Irm with the ATE score and Apo (orthogonal signal on the basis).

Source

pub fn gate(&self, groups: ArrayView2<'_, f64>) -> Result<Blp>

Group average treatment effects for mutually exclusive groups given as 0/1 dummy columns (shape (n, n_groups)), as DoubleML’s gate.

Source

pub fn policy_tree( &self, features: ArrayView2<'_, f64>, depth: usize, min_samples_leaf: usize, ccp_alpha: f64, ) -> Result<PolicyTree>

Policy tree recommending treatment where the estimated effect is positive, as DoubleML’s policy_tree (for Irm with the ATE score, one treatment and one repetition). DoubleML’s defaults: depth = 2, min_samples_leaf = 8, ccp_alpha = 0.01.

Source

pub fn nuisance_loss(&self, name: &str) -> Option<ArrayView2<'_, f64>>

Out-of-sample loss of a nuisance learner, shape (n_treat, n_rep): RMSE for regression learners, log loss for classifiers (DoubleML’s nuisance_loss). Computed on the rows where the nuisance applies.

Source

pub fn nuisance_losses( &self, ) -> impl Iterator<Item = (&str, LossKind, ArrayView2<'_, f64>)>

(name, loss kind, losses) for every evaluated nuisance learner.

Source

pub fn nuisance_targets(&self, name: &str) -> Option<ArrayView3<'_, f64>>

Targets of a nuisance learner, shape (n, n_rep, n_treat), with NaN where the nuisance does not apply (to evaluate custom metrics).

Source

pub fn nuisance_names(&self) -> impl Iterator<Item = &str>

Names of the stored nuisance predictions (e.g. ml_l, ml_m).

Source

pub fn predictions(&self, name: &str) -> Option<ArrayView3<'_, f64>>

All predictions of one nuisance, shape (n, n_rep, k).

Source

pub fn prediction( &self, name: &str, rep: usize, treatment: usize, ) -> Option<Array1<f64>>

Out-of-fold predictions of one nuisance for a repetition and treatment.

Source§

impl DmlFit

Source

pub fn concat(fits: &[DmlFit]) -> Result<DmlFit>

Stack fits of the same data and sample splits into one fit with all their estimates (DoubleML’s concat), for joint inference: the bootstrap, simultaneous confidence bands and linear combinations then account for the correlation between the estimates.

Predictions and learner losses are stacked by nuisance name (NaN where a fit has no such nuisance); sensitivity elements are kept if every fit has them.

Source§

impl DmlFit

Source

pub fn sensitivity_analysis( &self, params: &SensitivityParams, ) -> Result<SensitivityResult>

Bounds on θ, their confidence bounds and robustness values under the confounding scenario params (PLR, IRM and DID models).

Source

pub fn sensitivity_elements( &self, ) -> Option<(ArrayView2<'_, f64>, ArrayView2<'_, f64>)>

Sensitivity elements (σ², ν²), each of shape (n_treat, n_rep): the residual variance of the outcome and the variance of the Riesz representer. None for models without sensitivity analysis.

Source

pub fn sensitivity_benchmark( &self, short: &DmlFit, ) -> Result<SensitivityBenchmark>

Calibrate a confounding scenario against observed covariates: short must be the same model refitted on the same sample splits without the benchmarking covariates (see sensitivity_benchmark on the models).

Trait Implementations§

Source§

impl Clone for DmlFit

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DmlFit

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for DmlFit

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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