sportran.md.tools.acf¶
Functions
|
Autocorrelation function for 1d arrays. |
|
Autocovariance for 1D |
|
cross-correlation function for 1d |
|
crosscovariance for 1D |
|
Returns True if 'data' contains missing entries, otherwise False |
|
Returns the integral function of acf, i.e. its integral as a function of the upper integration limit. Supports multi-component (N, N_COMP) arrays. Trapezial integration is used. tau[i] = trapz_{0}^{i} acf. |
- sportran.md.tools.acf.acf(x, unbiased=False, nlags=40, qstat=False, fft=False, alpha=None, missing='none')¶
Autocorrelation function for 1d arrays.
- Parameters
x (array) – Time series data
unbiased (bool) – If True, then denominators for autocovariance are n-k, otherwise n
nlags (int, optional) – Number of lags to return autocorrelation for.
qstat (bool, optional) – If True, returns the Ljung-Box q statistic for each autocorrelation coefficient. See q_stat for more information.
fft (bool, optional) – If True, computes the ACF via FFT.
alpha (scalar, optional) – If a number is given, the confidence intervals for the given level are returned. For instance if alpha=.05, 95 % confidence intervals are returned where the standard deviation is computed according to Bartlett’s formula.
missing (str, optional) – A string in [‘none’, ‘raise’, ‘conservative’, ‘drop’] specifying how the NaNs are to be treated.
- Returns
acf (array) – autocorrelation function
confint (array, optional) – Confidence intervals for the ACF. Returned if confint is not None.
qstat (array, optional) – The Ljung-Box Q-Statistic. Returned if q_stat is True.
pvalues (array, optional) – The p-values associated with the Q-statistics. Returned if q_stat is True.
Notes
The acf at lag 0 (ie., 1) is returned.
This is based np.correlate which does full convolution. For very long time series it is recommended to use fft convolution instead.
If unbiased is true, the denominator for the autocovariance is adjusted but the autocorrelation is not an unbiased estimtor.
References
- 1
Parzen, E., 1963. On spectral analysis with missing observations and amplitude modulation. Sankhya: The Indian Journal of Statistics, Series A, pp.383-392.
- sportran.md.tools.acf.acovf(x, unbiased=False, demean=True, fft=False, missing='none')¶
Autocovariance for 1D
- Parameters
x (array) – Time series data. Must be 1d.
unbiased (bool) – If True, then denominators is n-k, otherwise n
demean (bool) – If True, then subtract the mean x from each element of x
fft (bool) – If True, use FFT convolution. This method should be preferred for long time series.
missing (str) – A string in [‘none’, ‘raise’, ‘conservative’, ‘drop’] specifying how the NaNs are to be treated.
- Returns
acovf – autocovariance function
- Return type
array
References
- 1
Parzen, E., 1963. On spectral analysis with missing observations and amplitude modulation. Sankhya: The Indian Journal of Statistics, Series A, pp.383-392.
- sportran.md.tools.acf.ccf(x, y, unbiased=True)¶
cross-correlation function for 1d
- Parameters
x, y (arrays) – time series data
unbiased (boolean) – if True, then denominators for autocovariance is n-k, otherwise n
- Returns
ccf – cross-correlation function of x and y
- Return type
array
Notes
This is based np.correlate which does full convolution. For very long time series it is recommended to use fft convolution instead.
If unbiased is true, the denominator for the autocovariance is adjusted but the autocorrelation is not an unbiased estimtor.
- sportran.md.tools.acf.ccovf(x, y, unbiased=True, demean=True)¶
crosscovariance for 1D
- Parameters
x, y (arrays) – time series data
unbiased (boolean) – if True, then denominators is n-k, otherwise n
- Returns
ccovf – autocovariance function
- Return type
array
Notes
This uses np.correlate which does full convolution. For very long time series it is recommended to use fft convolution instead.
- sportran.md.tools.acf.has_missing(data)¶
Returns True if ‘data’ contains missing entries, otherwise False
- sportran.md.tools.acf.integrate_acf(acf)¶
Returns the integral function of acf, i.e. its integral as a function of the upper integration limit. Supports multi-component (N, N_COMP) arrays. Trapezial integration is used.
tau[i] = trapz_{0}^{i} acf