cor.mat {imagefx} | R Documentation |
Correlate Matrix Rows
Description
Wrapper function of ccf used to find best lag time between two vectors.
Usage
cor.mat(x, y, ...)
Arguments
x |
Vector. |
y |
Vector. |
... |
Additional arguments to pass to ccf (e.g. |
Value
Scalar indicating the lag associated with the maximum correlation value between x
and y
.
Author(s)
Alex J.C. Witsil
See Also
Examples
## generate a time axis
tax = seq(0,10,by=0.1)
## generate two signals with a phase offset
sig1 <- sin(2*pi*1/2*tax)
sig2 <- sin(2*pi*1/2*tax + pi/2)
best.lag <- cor.mat(sig1,sig2)
################
### PLOTTING ###
################
plot(sig1,type='l',col='blue',main=paste('lag is: ',best.lag,sep=''))
lines(sig2,col='green')
[Package imagefx version 0.4.1 Index]