Expand description
A Rust implementation of the Oaxaca-Blinder decomposition method.
This library provides tools to decompose the mean difference in an outcome variable between two groups into an “explained” part (due to differences in observable characteristics) and an “unexplained” part (due to differences in the returns to those characteristics).
Currently, the library supports numerical predictors and calculates standard errors using bootstrapping.
§Example
ⓘ
use polars::prelude::*;
use oaxaca_blinder::OaxacaBuilder;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let df = df!(
"wage" => &[10.0, 12.0, 11.0, 13.0, 15.0, 20.0, 22.0, 21.0, 23.0, 25.0],
"education" => &[12.0, 16.0, 14.0, 16.0, 18.0, 12.0, 16.0, 14.0, 16.0, 18.0],
"gender" => &["F", "F", "F", "F", "F", "M", "M", "M", "M", "M"]
)?;
let results = OaxacaBuilder::new(df, "wage", "gender", "F")
.predictors(&["education"])
.run()?;
results.summary();
Ok(())
}§Quantile Regression Decomposition
ⓘ
use polars::prelude::*;
use oaxaca_blinder::QuantileDecompositionBuilder;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let df = df!(
"wage" => &[10.0, 12.0, 11.0, 13.0, 15.0, 20.0, 22.0, 21.0, 23.0, 25.0, 9.0, 18.0],
"education" => &[12.0, 16.0, 14.0, 16.0, 18.0, 12.0, 16.0, 14.0, 16.0, 18.0, 10.0, 20.0],
"gender" => &["F", "F", "F", "F", "F", "F", "M", "M", "M", "M", "M", "M"]
)?;
let results = QuantileDecompositionBuilder::new(df, "wage", "gender", "F")
.predictors(&["education"])
.quantiles(&[0.25, 0.5, 0.75])
.run()?;
results.summary();
Ok(())
}Re-exports§
pub use crate::quantile_decomposition::QuantileDecompositionBuilder;pub use crate::jmp::decompose_changes;pub use crate::dfl::run_dfl;pub use crate::heckman::heckman_two_step;pub use crate::akm::AkmBuilder;pub use crate::akm::AkmResult;pub use crate::matching::engine::MatchingEngine;
Modules§
Structs§
- Budget
Adjustment - Represents a recommended adjustment for an individual to improve pay equity.
- Component
Result - Represents the calculated result for a single component or variable.
- Decomposition
Detail - Represents a component of the decomposition (e.g., two-fold or three-fold).
- Oaxaca
Builder - The main entry point for configuring and running an Oaxaca-Blinder decomposition.
- Oaxaca
Results - Holds all the results from the Oaxaca-Blinder decomposition.
- TwoFold
Results - Holds results for the two-fold decomposition, including detailed components.
Enums§
- Oaxaca
Error - Error type for the
oaxaca_blinderlibrary. - Reference
Coefficients - Represents the choice of reference coefficients for the two-fold decomposition.