

def _compute_multivariate_sample_acovf(endog, maxlag):
    "\n    Computer multivariate sample autocovariances\n\n    Parameters\n    ----------\n    endog : array_like\n        Sample data on which to compute sample autocovariances. Shaped\n        `nobs` x `k_endog`.\n\n    Returns\n    -------\n    sample_autocovariances : list\n        A list of the first `maxlag` sample autocovariance matrices. Each\n        matrix is shaped `k_endog` x `k_endog`.\n\n    Notes\n    -----\n    This function computes the forward sample autocovariances:\n\n    .. math::\n\n        \\hat \\Gamma(s) = \x0crac{1}{n} \\sum_{t=1}^{n-s}\n        (Z_t - \x08ar Z) (Z_{t+s} - \x08ar Z)'\n\n    See page 353 of Wei (1990). This function is primarily implemented for\n    checking the partial autocorrelation functions below, and so is quite slow.\n\n    References\n    ----------\n    .. [1] Wei, William. 1990.\n        Time Series Analysis : Univariate and Multivariate Methods.\n       Boston: Pearson.\n    "
    endog = np.array(endog)
    if (endog.ndim == 1):
        endog = endog[:, np.newaxis]
    endog -= np.mean(endog, axis=0)
    (nobs, k_endog) = endog.shape
    sample_autocovariances = []
    for s in range((maxlag + 1)):
        sample_autocovariances.append(np.zeros((k_endog, k_endog)))
        for t in range((nobs - s)):
            sample_autocovariances[s] += np.outer(endog[t], endog[(t + s)])
        sample_autocovariances[s] /= nobs
    return sample_autocovariances

dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/tsa/statespace/tools.py _compute_multivariate_sample_acovf/original