Skip to main content

python_white_method

Function python_white_method 

Source
pub fn python_white_method(
    y: &[f64],
    x_vars: &[Vec<f64>],
) -> Result<WhiteSingleResult>
Expand description

Performs the White test for heteroscedasticity using Python’s method.

This implementation matches Python’s statsmodels.stats.diagnostic.het_white() function. Uses the LINPACK QR decomposition with column pivoting and the Python-specific auxiliary matrix structure (intercept, X, X², and cross-products).

§Arguments

  • y - Dependent variable values
  • x_vars - Independent variables (each vec is a column)

§Returns

A WhiteSingleResult containing the LM statistic and p-value.

§Example

let y = vec![2.0, 4.0, 6.0, 8.0, 10.0, 12.0];
let x1 = vec![1.0, 2.0, 3.0, 4.0, 5.0, 6.0];
let x2 = vec![2.0, 3.0, 4.0, 5.0, 6.0, 7.0];

let result = python_white_method(&y, &[x1, x2]).unwrap();

println!("LM statistic: {}", result.statistic);
println!("P-value: {}", result.p_value);