Module diagnostics

Module diagnostics 

Source
Expand description

Statistical diagnostic tests for linear regression assumptions.

This module provides a comprehensive suite of diagnostic tests to validate the assumptions of ordinary least squares (OLS) regression. Each test is implemented in its own file for easier maintenance.

§Available Tests

§Linearity Tests

  • Rainbow Test (rainbow.rs) - Tests whether the relationship between predictors and response is linear
  • Harvey-Collier Test (harvey_collier.rs) - Tests for functional form misspecification using recursive residuals

§Heteroscedasticity Tests

  • Breusch-Pagan Test (breusch_pagan.rs) - Tests for constant variance of residuals (studentized/Koenker variant)
  • White Test (white.rs) - More general test for heteroscedasticity that does not assume a specific form

§Normality Tests

  • Jarque-Bera Test (jarque_bera.rs) - Tests normality using skewness and kurtosis
  • Shapiro-Wilk Test (shapiro_wilk.rs) - Powerful normality test for small to moderate samples (n ≤ 5000)
  • Anderson-Darling Test (anderson_darling.rs) - Tail-sensitive test for normality

§Autocorrelation Tests

  • Durbin-Watson Test (durbin_watson.rs) - Tests for first-order autocorrelation in residuals

§Influence Measures

  • Cook’s Distance (cooks_distance.rs) - Identifies influential observations that may affect regression results

Structs§

CooksDistanceResult
Result of Cook’s distance analysis.
DiagnosticTestResult
Result of a diagnostic test.
DurbinWatsonResult
Result of the Durbin-Watson test
RainbowSingleResult
Result of the Rainbow test for a single method (R or Python).
RainbowTestOutput
Result of the Rainbow test supporting both R and Python variants.
WhiteSingleResult
Result of the White test for a single method (R or Python).
WhiteTestOutput
Result of the White test supporting both R and Python variants.

Enums§

RainbowMethod
Rainbow test implementation method.
WhiteMethod
White test implementation method.

Functions§

anderson_darling_test
Performs the Anderson-Darling test for normality of residuals.
anderson_darling_test_raw
Applies the Anderson-Darling test directly to a sample of values.
breusch_pagan_test
Performs the Breusch-Pagan test for heteroscedasticity.
cooks_distance_test
Computes Cook’s distance for identifying influential observations.
durbin_watson_test
Durbin-Watson test for first-order autocorrelation in residuals.
f_p_value
Computes a p-value from an F-statistic.
harvey_collier_test
Performs the Harvey-Collier test for linearity (functional form).
jarque_bera_test
Performs the Jarque-Bera test for normality of residuals.
python_white_method
Performs the White test for heteroscedasticity using Python’s method.
r_white_method
Performs the White test for heteroscedasticity using R’s method.
rainbow_test
Rainbow test with method selection (R, Python, or Both).
shapiro_wilk_test
Performs the Shapiro-Wilk test for normality of residuals.
shapiro_wilk_test_raw
Applies the Shapiro-Wilk test directly to a sample of values.
two_tailed_p_value
Computes a two-tailed p-value from a t-statistic.
validate_regression_data
Validates regression input data for dimensions and finite values.
white_test
Performs the White test for heteroscedasticity.