solow_impute/lib.rs
1//! # solow-impute
2//!
3//! The deterministic core of multiple imputation by chained equations (MICE).
4//!
5//! Multiple imputation has two ingredients: a stochastic step that draws
6//! plausible replacements for missing values, and a deterministic step that
7//! combines the analyses of the completed data sets back into a single
8//! inference. This crate implements the deterministic pieces, which are exactly
9//! reproducible and can be validated against an authoritative reference:
10//!
11//! * [`combine`] applies Rubin's combining rules to per-imputation parameter
12//! estimates and covariance matrices, returning the pooled estimate, the
13//! within/between/total covariance, the fraction of missing information, and
14//! the Barnard–Rubin degrees of freedom.
15//! * [`conditional_mean_impute`] performs a single deterministic
16//! conditional-mean (regression) imputation of one variable given the others.
17//!
18//! The stochastic posterior draws that drive a full MICE run depend on a random
19//! number generator and are intentionally out of scope here.
20//!
21//! ```
22//! use ndarray::array;
23//! use solow_impute::combine;
24//!
25//! let p1 = array![1.0, 2.0];
26//! let p2 = array![1.2, 1.8];
27//! let c1 = array![[0.04, 0.0], [0.0, 0.05]];
28//! let c2 = array![[0.05, 0.0], [0.0, 0.06]];
29//! let res = combine(&[p1, p2], &[c1, c2], f64::INFINITY).unwrap();
30//! assert!((res.params[0] - 1.1).abs() < 1e-12);
31//! ```
32
33mod combine;
34mod iterative;
35mod knn;
36mod regression;
37mod simple;
38
39pub use combine::{combine, CombinedEstimate};
40pub use iterative::IterativeImputer;
41pub use knn::KnnImputer;
42pub use regression::{conditional_mean_impute, ConditionalMeanImputation};
43pub use simple::{SimpleImputer, SimpleStrategy};