TimeSeriesSRC.uniChi¶
- TimeSeriesSRC.uniChi(pmod, y, k=20, alpha=0.05)¶
Box-Pierce portmanteau chi-square test on one-step-ahead residuals.
Tests the null hypothesis that the residuals of a fitted model are white noise. Large values of the Q statistic (small p-values) indicate that the residuals are autocorrelated and the model does not adequately fit the data.
- Parameters:
pmod (pmodel) – Estimated prediction model (returned by
estimate()).y (array-like) – 1-D desired output sequence used to compute residuals.
k (int, optional) – Number of residual-ACF lags used in the Q statistic. Default 20.
alpha (float, optional) – Significance level for the test (probability of Type I error). Default 0.05.
- Returns:
passed (int) – 1 if the test is passed (residuals appear white), 0 otherwise.
q (float) – Box-Pierce Q statistic.
n (int) – Degrees of freedom (
kminus the number of free parameters).pval (float) – p-value of the Q statistic under the chi-square distribution.
Examples
>>> import numpy as np >>> from scipy.signal import lfilter >>> from TimeSeriesSRC.Model.model import pmodel >>> from TimeSeriesSRC.Model.estimate import estimate >>> from TimeSeriesSRC.basefunctions.uniChi import func_uniChi >>> e = np.random.default_rng(0).standard_normal(500) >>> y = lfilter([1, 0.5], [1, -0.8], e) >>> pm = pmodel('arma', nc=[1], nd=[1], diff=[0], per=[]) >>> pm_est, trec, stat = estimate(pm, y, show_plot=False, show_output=False) >>> passed, q, n, pval = func_uniChi(pm_est, y)