mod table;
mod trajectory;
use crate::{
datasets::{MissingMechanism, MissingMethod},
models::Labelled,
types::{Error, Labels, Result},
};
#[derive(Clone, Debug)]
pub struct BE<'a, D, T> {
dataset: &'a D,
missing_method: Option<MissingMethod>,
missing_mechanism: Option<MissingMechanism>,
prior: T,
}
impl<'a, D> BE<'a, D, ()> {
#[inline]
pub const fn new(dataset: &'a D) -> Self {
Self {
dataset,
missing_method: None,
missing_mechanism: None,
prior: (),
}
}
}
impl<'a, D, T> BE<'a, D, T> {
#[inline]
pub fn with_missing_method(
mut self,
missing_method: Option<MissingMethod>,
missing_mechanism: Option<MissingMechanism>,
) -> Result<Self> {
match (missing_method, &missing_mechanism) {
(Some(MissingMethod::LW) | Some(MissingMethod::PW), Some(_)) => {
return Err(Error::InvalidParameter(
"missing_mechanism",
"must be None if missing_method is LW or PW",
));
}
(Some(MissingMethod::IPW) | Some(MissingMethod::AIPW), None) => {
return Err(Error::InvalidParameter(
"missing_mechanism",
"must be provided if missing_method is IPW or AIPW",
));
}
_ => {}
}
self.missing_method = missing_method;
self.missing_mechanism = missing_mechanism;
Ok(self)
}
#[inline]
pub fn with_prior<U>(self, prior: U) -> BE<'a, D, U> {
BE {
dataset: self.dataset,
missing_method: self.missing_method,
missing_mechanism: self.missing_mechanism,
prior,
}
}
}
impl<D, T> Labelled for BE<'_, D, T>
where
D: Labelled,
{
#[inline]
fn labels(&self) -> &Labels {
self.dataset.labels()
}
}