Description Usage Arguments Value Author(s) See Also Examples
Wrapper function of ccf used to find best lag time between two vectors.
1 |
x |
Vector. |
y |
Vector. |
... |
Additional arguments to pass to ccf (e.g. |
Scalar indicating the lag associated with the maximum correlation value between x
and y
.
Alex J.C. Witsil
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## 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')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.