pub struct PropensityScoreMatching {
pub weights: Vec<f64>,
pub n_covariates: usize,
}Expand description
Propensity score matching for observational causal inference.
Estimates the probability of treatment assignment P(T=1|X) using logistic regression, then matches treated and control units.
Fields§
§weights: Vec<f64>Logistic regression weights (length = n_covariates + 1, with intercept).
n_covariates: usizeNumber of covariates.
Implementations§
Source§impl PropensityScoreMatching
impl PropensityScoreMatching
Sourcepub fn fit(
&mut self,
covariates: &[Vec<f64>],
treatment: &[f64],
lr: f64,
n_iter: usize,
)
pub fn fit( &mut self, covariates: &[Vec<f64>], treatment: &[f64], lr: f64, n_iter: usize, )
Fit logistic regression to estimate propensity scores via gradient descent.
§Arguments
covariates— matrix of covariates, shape[n_obs][n_covariates]treatment— binary treatment indicator (0 or 1), lengthn_obslr— learning raten_iter— number of gradient descent iterations
Sourcepub fn predict_one(&self, x: &[f64]) -> f64
pub fn predict_one(&self, x: &[f64]) -> f64
Predict propensity score P(T=1|X=x) for a single observation.
Sourcepub fn predict(&self, covariates: &[Vec<f64>]) -> Vec<f64>
pub fn predict(&self, covariates: &[Vec<f64>]) -> Vec<f64>
Predict propensity scores for all observations.
Trait Implementations§
Source§impl Clone for PropensityScoreMatching
impl Clone for PropensityScoreMatching
Source§fn clone(&self) -> PropensityScoreMatching
fn clone(&self) -> PropensityScoreMatching
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PropensityScoreMatching
impl RefUnwindSafe for PropensityScoreMatching
impl Send for PropensityScoreMatching
impl Sync for PropensityScoreMatching
impl Unpin for PropensityScoreMatching
impl UnsafeUnpin for PropensityScoreMatching
impl UnwindSafe for PropensityScoreMatching
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.