pub fn test_autocorrelation<F, S1, S2, D1, D2>(
y_true: &ArrayBase<S1, D1>,
y_pred: &ArrayBase<S2, D2>,
) -> Result<F>Expand description
Checks for autocorrelation in residuals using Durbin-Watson test
§Arguments
y_true- Ground truth (correct) target valuesy_pred- Estimated target values
§Returns
- Durbin-Watson test statistic
§Examples
use scirs2_core::ndarray::array;
use scirs2_metrics::regression::test_autocorrelation;
let y_true = array![3.0, -0.5, 2.0, 7.0, 5.0, 8.0, 1.0, 4.0];
let y_pred = array![2.5, 0.0, 2.0, 8.0, 4.5, 7.5, 1.5, 3.5];
let dw_stat = test_autocorrelation(&y_true, &y_pred).unwrap();
// DW statistic ranges from 0 to 4, with 2 being no autocorrelation
assert!(dw_stat >= 0.0 && dw_stat <= 4.0);