WOLFRAM

CorrelationFunction[data,hspec]

estimates the correlation function at lags hspec from data.

CorrelationFunction[proc,hspec]

represents the correlation function at lags hspec for the random process proc.

represents the correlation function at times s and t for the random process proc.

Details

  • CorrelationFunction is also known as autocorrelation or cross-correlation function (ACF or CCF).
  • The following specifications can be given for hspec:
  • τat time or lag τ
    {τmax}unit spaced from 0 to τmax
    {τmin,τmax}unit spaced from τmin to τmax
    {τmin,τmax,dτ}from τmin to τmax in steps of dτ
    {{τ1,τ2,}}use explicit {τ1,τ2,}
  • CorrelationFunction[{x1,,xn},h] is equivalent to with =Mean[{x1,,xn}].
  • When data is TemporalData containing an ensemble of paths, the output represents the average across all paths.
  • CorrelationFunction of the process proc is the CovarianceFunction c normalized by the outer product of the standard deviation function σ at times s and t:
  • c[s,t]/(σ[s]σ[t])for scalar-valued data or processes
    c[s,t]/(σ[s] σ[t])for vector-valued data or processes
  • The symbol represents KroneckerProduct.
  • CorrelationFunction[proc,h] is defined only if proc is a weakly stationary process and is equivalent to CorrelationFunction[proc,h,0].
  • The process proc can be any random process, such as ARMAProcess and WienerProcess.

Examples

open allclose all

Basic Examples  (4)Summary of the most common use cases

Estimate the correlation function at lag 2:

Out[1]=1

The sample correlation function for a random sample from an autoregressive time series:

Out[2]=2

The correlation function for a discrete-time process:

Out[1]=1
Out[2]=2

The correlation function for a continuous-time process:

Out[1]=1
Out[2]=2

Scope  (13)Survey of the scope of standard use cases

Empirical Estimates  (7)

Estimate the correlation function for some data at lag 9:

Out[1]=1

Obtain empirical estimates of the correlation function up to lag 9:

Out[1]=1

Compute the correlation function for lags 1 to 9 in steps of 2:

Out[1]=1

Compute the correlation function for a time series:

The correlation function of a time series for multiple lags is given as a time series:

Out[2]=2
Out[3]=3

Estimate the correlation function for an ensemble of paths:

Out[1]=1
Out[3]=3

Compare empirical and theoretical correlation functions:

Out[3]=3

Plot the cross-correlation for vector data:

Out[2]=2

Random Processes  (6)

The correlation function for a weakly stationary discrete-time process:

Out[1]=1
Out[2]=2

The correlation function only depends on the antidiagonal :

Out[3]=3
Out[4]=4

The correlation function for a weakly stationary continuous-time process:

Out[1]=1
Out[2]=2

The correlation function only depends on the antidiagonal :

Out[3]=3
Out[4]=4

The correlation function for a non-weakly stationary discrete-time process:

Out[1]=1
Out[2]=2

The correlation function depends on both time arguments:

Out[3]=3
Out[4]=4

The correlation function for a non-weakly stationary continuous-time process:

Out[1]=1
Out[2]=2

The correlation function depends on both time arguments:

Out[3]=3
Out[4]=4

The correlation function for some time series processes:

Out[2]=2

Cross-correlation plots for a vector ARProcess:

Out[2]=2

Applications  (2)Sample problems that can be solved with this function

Determine whether the following data is best modeled with an MAProcess or an ARProcess:

Out[2]=2

It is difficult to determine the underlying process from sample paths:

Out[4]=4

The correlation function of the data decays slowly:

Out[5]=5

ARProcess is clearly a better candidate model than MAProcess:

Out[6]=6

Create an ACF plot with white-noise confidence bands:

Plot the correlation for lags 0 to 20 with 95% white-noise confidence bands:

Out[3]=3

Compare to uncorrelated white noise:

Out[4]=4

Properties & Relations  (12)Properties of the function, and connections to other functions

Sample correlation function is a biased estimator for the process correlation function:

Calculate the sample correlation function:

Out[13]=13
Out[14]=14

Correlation function for the process:

Out[15]=15

Plot both functions:

Out[16]=16

Correlation function for a process is the off-diagonal entry in the Correlation matrix:

Out[2]=2
Out[3]=3
Out[4]=4

Sample correlation at lag 0 is always 1:

Out[1]=1

Sample correlation function is related to CovarianceFunction:

Out[2]=2

Scaled sample covariance function:

Out[3]=3
Out[4]=4

Sample correlation function is related to AbsoluteCorrelationFunction:

Out[2]=2

Scale by the first element:

Out[3]=3

Compare to the sample correlation function:

Out[4]=4
Out[5]=5

Use Expectation to calculate correlation:

Define mean and standard deviation functions:

Out[3]=3
Out[4]=4
Out[5]=5

Correlation function for equal times reduces to 1:

Out[1]=1

Correlation function is related to the CovarianceFunction :

Out[2]=2

For , the standard deviation function is :

Out[3]=3
Out[4]=4

The correlation function is related to the Correlation:

Out[2]=2

It is the off-diagonal entry in the covariance matrix:

Out[3]=3
Out[4]=4

Correlation function is invariant for ToInvertibleTimeSeries:

Out[1]=1
Out[2]=2
Out[3]=3

Correlation function is invariant to centralizing:

The data has nonzero mean:

Out[2]=2

Centralize data:

Compare correlation functions:

Out[4]=4

Sum of the sample correlation function is constant:

The sample is random:

Out[2]=2

Calculate the sample correlation function from 1 to n-1:

Out[3]=3

Calculate the sum:

Out[4]=4

Possible Issues  (1)Common pitfalls and unexpected behavior

CorrelationFunction output may contain DifferenceRoot:

Out[1]=1

Use FunctionExpand to recover explicit powers:

Out[2]=2
Wolfram Research (2012), CorrelationFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/CorrelationFunction.html.
Wolfram Research (2012), CorrelationFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/CorrelationFunction.html.

Text

Wolfram Research (2012), CorrelationFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/CorrelationFunction.html.

Wolfram Research (2012), CorrelationFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/CorrelationFunction.html.

CMS

Wolfram Language. 2012. "CorrelationFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CorrelationFunction.html.

Wolfram Language. 2012. "CorrelationFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/CorrelationFunction.html.

APA

Wolfram Language. (2012). CorrelationFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CorrelationFunction.html

Wolfram Language. (2012). CorrelationFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/CorrelationFunction.html

BibTeX

@misc{reference.wolfram_2024_correlationfunction, author="Wolfram Research", title="{CorrelationFunction}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/CorrelationFunction.html}", note=[Accessed: 10-January-2025 ]}

@misc{reference.wolfram_2024_correlationfunction, author="Wolfram Research", title="{CorrelationFunction}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/CorrelationFunction.html}", note=[Accessed: 10-January-2025 ]}

BibLaTeX

@online{reference.wolfram_2024_correlationfunction, organization={Wolfram Research}, title={CorrelationFunction}, year={2012}, url={https://reference.wolfram.com/language/ref/CorrelationFunction.html}, note=[Accessed: 10-January-2025 ]}

@online{reference.wolfram_2024_correlationfunction, organization={Wolfram Research}, title={CorrelationFunction}, year={2012}, url={https://reference.wolfram.com/language/ref/CorrelationFunction.html}, note=[Accessed: 10-January-2025 ]}