acf
Syntax
acf(X, maxLag)
Details
Computes the autocorrelation of X from lag=1 to lag=maxLag. Note that the means of the two time series used in the calculation is the mean of X instead of the means of the two time series.
This function is largely consistent with
statsmodels.tsa.stattools.acf in terms of computing
autocorrelation coefficients. The specific implementation differences are as
follows:
| Dimension | DolphinDB acf |
Python statsmodels.tsa.acf |
|---|---|---|
| lag parameter | maxLag must be specified | Optional; default is min(10 * np.log10(nobs), nobs -
1) |
| Computation method | Demeaning + normalization | Demeaning + normalization (default); normalization can be adjusted via the adjusted parameter |
| FFT acceleration | Supported (not configurable) | Supported (controlled by the fft parameter) |
| Confidence interval | Not supported | Supports confidence intervals via alpha and method selection via bartlett_confint |
| Significance test | Not supported | Supported (via the qstat parameter) |
| Missing value handling | Not supported (throws error) | Supported (via the missing parameter) |
| Return value | Vector of autocorrelation coefficients from lag 1 to maxLag | Array of autocorrelation coefficients + optional confidence intervals |
Parameters
X is a vector.
maxLag is a positive integer that specifies the maximum lag for computing the autocorrelation coefficient.
Examples
n=10000
x=array(double, n, n, NULL)
x[0]=1
r=rand(0.05, n)-0.025
for(i in 0:(n-1)){
x[i+1]=-0.8*x[i]+r[i]
}
acf = acf(x, 20)
plot(acf,chartType=BAR)
