ssfortran.diagnostics.ljung_box#
- ssfortran.diagnostics.ljung_box(x, lags=10, model_df=0)#
Test for serial correlation with the Ljung-Box statistic.
\(Q(k) = n (n + 2) \sum_{j=1}^k \rho_j^2 / (n - j)\), referred to \(\chi^2\) with k - model_df degrees of freedom (DK §2.12.1).
- Parameters:
- xarray_like
Residuals.
- lagsint, optional
Largest lag k.
- model_dfint, optional
Degrees of freedom to subtract, e.g. the number of ARMA coefficients.
- Returns:
- statndarray, shape (lags,)
\(Q(1), \dots, Q(k)\).
- pvaluendarray, shape (lags,)
Their p-values.
Notes
Pairs with a NaN are skipped, and n is the number of non-NaN values.
Examples
>>> e = np.random.default_rng(0).standard_normal(200) >>> stat, pvalue = ss.diagnostics.ljung_box(e, lags=5) >>> stat.shape (5,)