TimeSeriesSRC.multiChi

TimeSeriesSRC.multiChi(pmod, y, u, k1=20, k2=20, alpha1=0.05, alpha2=0.05)

Multivariate chi-square tests for transfer function model validation.

Performs two hypothesis tests on a fitted transfer function model:

  1. Residual whiteness — Box-Pierce Q statistic on the one-step-ahead residuals e. Tests whether the noise model H(q) is adequate.

  2. Residual/input independence — cross-correlation statistic S between the pre-whitened input u and the residuals e. Tests whether the transfer function G(q) is adequate.

Parameters:
  • pmod (pmodel) – Estimated prediction model (ARX, ARMAX, or BJTF).

  • y (array-like) – 1-D desired output sequence.

  • u (array-like) – 1-D or 2-D input sequence, shape (N,) or (1, N).

  • k1 (int, optional) – Residual-ACF lags for the Q statistic. Default 20.

  • k2 (int, optional) – Cross-correlation lags for the S statistic. Default 20.

  • alpha1 (float, optional) – Significance level for the residual whiteness test. Default 0.05.

  • alpha2 (float, optional) – Significance level for the cross-correlation test. Default 0.05.

Returns:

  • pass_arr (list of int) – [pass_Q, pass_S] — 1 if the test passes, 0 otherwise.

  • q (float) – Box-Pierce Q statistic (residual autocorrelation).

  • pvalq (float) – p-value for Q.

  • s (float) – Cross-correlation chi-square statistic.

  • pvals (float) – p-value for S.

  • nq (int) – Degrees of freedom for Q.

  • ns (int) – Degrees of freedom for S.

Examples

>>> import pathlib, pandas as pd
>>> import TimeSeriesSRC as ts
>>> data_dir = pathlib.Path(ts.__file__).parent / 'TestData'
>>> df  = pd.read_csv(data_dir / 'Series_J_Gas_Furnace.csv')
>>> u   = df.iloc[:, 0].values
>>> y   = df.iloc[:, 1].values
>>> pm  = ts.pmodel('arx', na=[2], nb=[2], delay=[3])
>>> pm_est, trec, stat = ts.estimate(pm, y, u=u,
...                                  show_plot=False, show_output=False)
>>> pass_arr, q, pvalq, s, pvals, nq, ns = ts.multiChi(pm_est, y, u)

See also

uniChi

Univariate chi-square test (ARMA models without input).

multiAnal

Impulse response and GPAC analysis for input-output data.