pub struct SpecificationTests;Expand description
Specification tests for regression models
Implementations§
Source§impl SpecificationTests
impl SpecificationTests
Sourcepub fn white_test(
residuals: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
x: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>,
) -> Result<(f64, f64, usize), String>
pub fn white_test( residuals: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, x: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ) -> Result<(f64, f64, usize), String>
White’s Test for Heteroskedasticity
Tests H₀: Homoskedasticity (constant variance) vs H₁: Heteroskedasticity
§Arguments
residuals- Residuals from OLS regressionx- Design matrix (n × k)
§Returns
Tuple of (LM_statistic, p_value, degrees_of_freedom)
§Interpretation
- If p < 0.05: Reject H₀, heteroskedasticity is present (use robust SE)
- If p > 0.05: Fail to reject H₀, homoskedasticity is plausible
use greeners_diagnostics::specification_tests::SpecificationTests;
use ndarray::{Array1, Array2};
// ... the rest of your original example here ...
let (lm_stat, p_value, df) = SpecificationTests::white_test(&residuals, &x)?;Sourcepub fn reset_test(
y: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
x: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>,
fitted_values: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
power: usize,
) -> Result<(f64, f64, usize, usize), String>
pub fn reset_test( y: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, x: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, fitted_values: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, power: usize, ) -> Result<(f64, f64, usize, usize), String>
Ramsey RESET Test for Functional Form Misspecification
Tests H₀: Model is correctly specified vs H₁: Functional form misspecification
§Arguments
y- Dependent variablex- Design matrix (n × k)fitted_values- Fitted values from original regressionpower- Maximum power of fitted values to include (typically 2, 3, or 4)
§Returns
Tuple of (F_statistic, p_value, df_num, df_denom)
§Interpretation
- If p < 0.05: Reject H₀, functional form misspecification detected
- If p > 0.05: Fail to reject H₀, functional form appears adequate
use greeners_diagnostics::specification_tests::SpecificationTests;
use ndarray::{Array1, Array2};
let (f_stat, p_value, _, _) = SpecificationTests::reset_test(&y, &x, &fitted, 2)?;Sourcepub fn breusch_godfrey_test(
residuals: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
x: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>,
lags: usize,
) -> Result<(f64, f64, usize), String>
pub fn breusch_godfrey_test( residuals: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, x: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, lags: usize, ) -> Result<(f64, f64, usize), String>
Breusch-Godfrey Test for Autocorrelation
Tests H₀: No autocorrelation up to lag p vs H₁: Autocorrelation present
§Arguments
residuals- Residuals from OLS regressionx- Design matrix (n × k)lags- Number of lags to test (typically 1 for AR(1))
§Returns
Tuple of (LM_statistic, p_value, degrees_of_freedom)
§Interpretation
- If p < 0.05: Reject H₀, autocorrelation detected
- If p > 0.05: Fail to reject H₀, no evidence of autocorrelation
§Examples
use greeners_diagnostics::specification_tests::SpecificationTests;
use ndarray::{Array1, Array2};
// The visible example starts here:
let (lm_stat, p_value, df) = SpecificationTests::breusch_godfrey_test(&residuals, &x, 1)?;Sourcepub fn goldfeld_quandt_test(
residuals: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
split_fraction: f64,
) -> Result<(f64, f64, usize, usize), String>
pub fn goldfeld_quandt_test( residuals: &ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, split_fraction: f64, ) -> Result<(f64, f64, usize, usize), String>
Goldfeld-Quandt Test for Heteroskedasticity
Tests H₀: Homoskedasticity vs H₁: Variance increases with ordering variable
§Arguments
residuals- Residuals from OLS regression (should be ordered by suspected variable)split_fraction- Fraction of middle observations to drop (typically 0.2 to 0.33)
§Returns
Tuple of (F_statistic, p_value, df1, df2)
§Interpretation
- If p < 0.05: Reject H₀, heteroskedasticity detected
- If p > 0.05: Fail to reject H₀, homoskedasticity plausible
Auto Trait Implementations§
impl Freeze for SpecificationTests
impl RefUnwindSafe for SpecificationTests
impl Send for SpecificationTests
impl Sync for SpecificationTests
impl Unpin for SpecificationTests
impl UnsafeUnpin for SpecificationTests
impl UnwindSafe for SpecificationTests
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> SendAlias for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.