Skip to main content

vif

Function vif 

Source
pub fn vif(predictors: &[&[f64]]) -> Option<Vec<f64>>
Expand description

Computes the Variance Inflation Factor for each predictor.

VIF_j = 1 / (1 - R²_j), where R²_j is the coefficient of determination from regressing predictor j on all other predictors. Standard thresholds are VIF > 5 (moderate multicollinearity) and VIF > 10 (severe).

§Returns

None if predictors is empty, lengths differ, fewer than p+1 observations, or any predictor contains a non-finite value. With a single predictor, returns Some(vec![1.0]) since VIF is undefined for one regressor.

§References

Marquardt (1970). “Generalized inverses, ridge regression.” Belsley, Kuh, Welsch (1980). Regression Diagnostics.

§Examples

use u_analytics::regression::vif;

let x1 = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0];
let x2 = [8.0, 1.0, 6.0, 3.0, 5.0, 7.0, 2.0, 4.0];
let v = vif(&[&x1, &x2]).unwrap();
assert!(v[0] < 2.0); // independent predictors