- acf(x, lags=365, bin_method='rectangle', bin_width=0.5, max_gap=inf, min_obs=20, full_output=False, alpha=0.05)#
Calculate the autocorrelation function for irregular time steps.
x (pandas.Series) – Pandas Series containing the values to calculate the cross-correlation on. The index has to be a Pandas.DatetimeIndex.
lags (array_like, optional) – numpy array containing the lags in days for which the cross-correlation if calculated. [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 30, 61, 90, 120, 150, 180, 210, 240, 270, 300, 330, 365].
bin_method (str, optional) – method to determine the type of bin. Options are “rectangle” (default), and “gaussian”.
bin_width (float, optional) – number of days used as the width for the bin to calculate the correlation. By default, these values are chosen based on the bin_method and the average time step (dt_mu). That is 0.5dt_mu when bin_method=”rectangle” and 0.25dt_mu when bin_method=”gaussian”.
max_gap (float, optional) – Maximum time step gap in the data. All time steps above this gap value are not used for calculating the average time step. This can be helpful when there is a large gap in the data that influences the average time step.
min_obs (int, optional) – Minimum number of observations in a bin to determine the correlation.
full_output (bool, optional) – If True, also estimated uncertainties are returned. Default is False.
alpha (float) – alpha level to compute the confidence interval (e.g., 1-alpha).
result – If full_output=True, a DataFrame with columns “acf”, “conf”, and “n”, containning the autocorrelation function, confidence intervals (depends on alpha), and the number of samples n used to compute these, respectively. If full_output=False, only the ACF is returned.
- Return type:
Calculate the autocorrelation function for irregular timesteps based on the slotting technique. Different methods (kernels) to bin the data are available. Method here is based on Rehfeld et al. (2011).
If the time series have regular time step we recommend to use the acf method from the Statsmodels package.
For example, to estimate the autocorrelation for every second lag up to lags of one year:
>>> acf = ps.stats.acf(x, lags=np.arange(1.0, 366.0, 2.0))