linreg_core/diagnostics/
mod.rs

1// ============================================================================
2// Diagnostics Module
3// ============================================================================
4
5//! Statistical diagnostic tests for linear regression assumptions.
6//!
7//! This module provides a comprehensive suite of diagnostic tests to validate
8//! the assumptions of ordinary least squares (OLS) regression. Each test is
9//! implemented in its own file for easier maintenance.
10//!
11//! # Available Tests
12//!
13//! ## Linearity Tests
14//!
15//! - **Rainbow Test** (`rainbow.rs`) - Tests whether the relationship between
16//!   predictors and response is linear
17//! - **Harvey-Collier Test** (`harvey_collier.rs`) - Tests for functional form
18//!   misspecification using recursive residuals
19//!
20//! ## Heteroscedasticity Tests
21//!
22//! - **Breusch-Pagan Test** (`breusch_pagan.rs`) - Tests for constant variance
23//!   of residuals (studentized/Koenker variant)
24//! - **White Test** (`white.rs`) - More general test for heteroscedasticity
25//!   that does not assume a specific form
26//!
27//! ## Normality Tests
28//!
29//! - **Jarque-Bera Test** (`jarque_bera.rs`) - Tests normality using skewness
30//!   and kurtosis
31//! - **Shapiro-Wilk Test** (`shapiro_wilk.rs`) - Powerful normality test for
32//!   small to moderate samples (n ≤ 5000)
33//! - **Anderson-Darling Test** (`anderson_darling.rs`) - Tail-sensitive test for
34//!   normality
35//!
36//! ## Autocorrelation Tests
37//!
38//! - **Durbin-Watson Test** (`durbin_watson.rs`) - Tests for first-order
39//!   autocorrelation in residuals
40//!
41//! ## Influence Measures
42//!
43//! - **Cook's Distance** (`cooks_distance.rs`) - Identifies influential
44//!   observations that may affect regression results
45
46// Submodules
47mod anderson_darling;
48mod breusch_pagan;
49mod cooks_distance;
50mod durbin_watson;
51mod harvey_collier;
52mod helpers;
53mod jarque_bera;
54mod rainbow;
55mod shapiro_wilk;
56mod types;
57mod white;
58
59// Re-export types
60pub use types::{
61    CooksDistanceResult, DiagnosticTestResult, RainbowMethod, RainbowSingleResult,
62    RainbowTestOutput, WhiteMethod, WhiteSingleResult, WhiteTestOutput,
63};
64
65// Re-export test functions
66pub use anderson_darling::{anderson_darling_test, anderson_darling_test_raw};
67pub use breusch_pagan::breusch_pagan_test;
68pub use cooks_distance::cooks_distance_test;
69pub use durbin_watson::{durbin_watson_test, DurbinWatsonResult};
70pub use harvey_collier::harvey_collier_test;
71pub use jarque_bera::jarque_bera_test;
72pub use rainbow::rainbow_test;
73pub use shapiro_wilk::{shapiro_wilk_test, shapiro_wilk_test_raw};
74pub use white::{python_white_method, r_white_method, white_test};
75
76// Re-export helper functions that are used elsewhere
77pub use helpers::{f_p_value, two_tailed_p_value, validate_regression_data};