crosscorr
Sample cross-correlation
Syntax
Description
[
returns the sample cross-correlation
function (XCF) xcf
,lags
] = crosscorr(y1
,y2
)xcf
and associated lags
lags
between the univariate time series
y1
and y2
.
returns the table XCFTbl
= crosscorr(Tbl
)XCFTbl
containing variables for the
sample XCF and associated lags of the last two variables in the input table or
timetable Tbl
. To select different variables in
Tbl
, for which to compute the XCF, use the
DataVariables
name-value argument.
[___,
uses any input-argument combination in the previous syntaxes, and returns the
output-argument combination for the corresponding input arguments and the
approximate upper and lower confidence bounds bounds
]
= crosscorr(___)bounds
on the
XCF.
[___] = crosscorr(___,
uses additional options specified by one or more name-value arguments. For
example, Name=Value
)crosscorr(Tbl,DataVariables=["RGDP"
"CPI"],NumLags=10,NumSTD=1.96)
returns the sample XCF for lags -10
through 10 of the table variables "RGDP"
and
"CPI"
in Tbl
and 95% confidence
bounds.
crosscorr(___)
plots the sample XCF between
the input series with confidence bounds.
crosscorr(
plots on the axes specified by ax
,___)ax
instead of
the current axes (gca
). ax
can precede any of the input
argument combinations in the previous syntaxes.
[___,
plots the sample XCF between the input series and additionally returns handles
to plotted graphics objects. Use elements of h
]
= crosscorr(___)h
to modify
properties of the plot after you create it.
Examples
Input Arguments
Output Arguments
More About
Algorithms
If
y1
andy2
have different lengths,crosscorr
appends enough zeros to the end of the shorter vector to make both vectors the same size.crosscorr
uses a Fourier transform (fft
) to compute the XCF in the frequency domain, and thencrosscorr
converts back to the time domain using an inverse Fourier transform (ifft
).NaN
values in the input series result inNaN
values in the output XCF. Unlikeautocorr
andparcorr
,crosscorr
does not treatNaN
values as missing completely at random. Whereasautocorr
andparcorr
compute coefficients in the time domain,crosscorr
usesfft
andifft
to compute coefficients in the frequency domain. Therefore, missing data treatments followfft
andifft
defaults.crosscorr
plots the XCF when you do not request any output or when you request the fourth output.
References
[1] Box, George E. P., Gwilym M. Jenkins, and Gregory C. Reinsel. Time Series Analysis: Forecasting and Control. 3rd ed. Englewood Cliffs, NJ: Prentice Hall, 1994.
Version History
Introduced before R2006a