'Test the whiteness of the residuals using the Portmanteau test as
described in [1]_, chapter 4.4.3.
Parameters
nlags : int > 0
signif : float, between 0 and 1
adjusted : bool, default False
Returns
results : WhitenessTestResults
References
.. [1] Lutkepohl, H. 2005. *New Introduction to Multiple Time Series Analysis*. Springer.'

def test_whiteness_new(self, nlags=10, signif=0.05, adjusted=False):

    statistic = 0
    u = np.asarray(self.resid)
    acov_list = _compute_acov(u, nlags)
    cov0_inv = L.inv(acov_list[0])
    for t in range(1, (nlags + 1)):
        ct = acov_list[t]
        to_add = np.trace(chain_dot(ct.T, cov0_inv, ct, cov0_inv))
        if adjusted:
            to_add /= (self.nobs - t)
        statistic += to_add
    statistic *= ((self.nobs ** 2) if adjusted else self.nobs)
    df = ((self.neqs ** 2) * (nlags - self.k_ar))
    dist = stats.chi2(df)
    pvalue = dist.sf(statistic)
    crit_value = dist.ppf((1 - signif))
    return WhitenessTestResults(statistic, crit_value, pvalue, df, signif, nlags, adjusted)
