Description Usage Arguments Value Examples
Get maximal cross-correlation between 2 numerical vectors. Only 1st position is returned.
1 |
x, |
y numerical vector |
use.circular |
logical, whether to use circular cross-correlation. |
plot |
logical. If TRUE, plots the cross-correlation histogram. |
... |
additional parameters for the cross-correlation if use.circular is FALSE. Of particular interest is lag.max. See ?ccf. |
A list of 2. $corr contains the maximum of correlation and $lag the lag at which it was reached.
1 2 3 4 5 6 7 8 9 | # 2 identical signals, shifted by a lag 3
pattern <- c(0.25, 0.5, 0.75, 1)
x <- rep(pattern, 10)
y <- c(x[4:length(x)],x[1:3])
par(mfrow=c(3,1))
plot(x, type = "h", main = "x", ylim = c(-0.2,1.2))
plot(y, type = "h", main = "y", ylim = c(-0.2,1.2))
# With circular cc, correlation is strictly 1
max_cc(x, y, use.circular = T, plot = T)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.