pub struct HypothesisTest;Expand description
Hypothesis testing methods
Implementations§
Source§impl HypothesisTest
impl HypothesisTest
Sourcepub fn wald_test(
beta: &Array1<f64>,
cov_matrix: &Array2<f64>,
r: &Array2<f64>,
q: &Array1<f64>,
) -> Result<(f64, f64, usize), GreenersError>
pub fn wald_test( beta: &Array1<f64>, cov_matrix: &Array2<f64>, r: &Array2<f64>, q: &Array1<f64>, ) -> Result<(f64, f64, usize), GreenersError>
Wald test for linear restrictions on coefficients
Tests H₀: R·β = q against H₁: R·β ≠ q
§Arguments
beta- Coefficient estimates (k × 1)cov_matrix- Variance-covariance matrix (k × k)r- Restriction matrix (m × k) where m = number of restrictionsq- Restriction values (m × 1), usually zeros
§Returns
Tuple of (wald_statistic, p_value, degrees_of_freedom)
§Examples
use greeners::HypothesisTest;
use ndarray::{Array1, Array2};
// Setup de dados falsos para o exemplo
let beta = Array1::from(vec![0.5, 2.0, 0.0]);
let cov_matrix = Array2::eye(3); // Matriz identidade como exemplo
// Testando se beta[1] = 0 e beta[2] = 0
let r = Array2::from_shape_vec((2, 3), vec![
0.0, 1.0, 0.0,
0.0, 0.0, 1.0,
])?;
let q = Array1::from(vec![0.0, 0.0]);
let (wald_stat, p_value, df) = HypothesisTest::wald_test(&beta, &cov_matrix, &r, &q)?;Sourcepub fn f_test_nested(
ssr_restricted: f64,
ssr_full: f64,
n: usize,
k_full: usize,
k_restricted: usize,
) -> Result<(f64, f64, usize, usize), GreenersError>
pub fn f_test_nested( ssr_restricted: f64, ssr_full: f64, n: usize, k_full: usize, k_restricted: usize, ) -> Result<(f64, f64, usize, usize), GreenersError>
F-test for nested models (OLS specific)
Tests whether restricted model is adequate vs full model
§Arguments
ssr_restricted- Sum of squared residuals from restricted modelssr_full- Sum of squared residuals from full modeln- Number of observationsk_full- Number of parameters in full modelk_restricted- Number of parameters in restricted model
§Returns
Tuple of (f_statistic, p_value, df_numerator, df_denominator)
§Formula
F = [(SSR_r - SSR_f) / (k_f - k_r)] / [SSR_f / (n - k_f)]
Sourcepub fn joint_significance(
beta: &Array1<f64>,
cov_matrix: &Array2<f64>,
has_intercept: bool,
) -> Result<(f64, f64, usize), GreenersError>
pub fn joint_significance( beta: &Array1<f64>, cov_matrix: &Array2<f64>, has_intercept: bool, ) -> Result<(f64, f64, usize), GreenersError>
Joint significance test (all coefficients except intercept = 0)
Convenience wrapper for Wald test of all slope coefficients
§Arguments
beta- Coefficient estimates (including intercept)cov_matrix- Variance-covariance matrixhas_intercept- Whether first coefficient is intercept
§Returns
Tuple of (test_statistic, p_value, degrees_of_freedom)
Auto Trait Implementations§
impl Freeze for HypothesisTest
impl RefUnwindSafe for HypothesisTest
impl Send for HypothesisTest
impl Sync for HypothesisTest
impl Unpin for HypothesisTest
impl UnwindSafe for HypothesisTest
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
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.