cor.mat: Correlate Matrix Rows

Description Usage Arguments Value Author(s) See Also Examples

View source: R/cor.mat.r

Description

Wrapper function of ccf used to find best lag time between two vectors.

Usage

1
cor.mat(x, y, ...)

Arguments

x

Vector.

y

Vector.

...

Additional arguments to pass to ccf (e.g. max.lag)

Value

Scalar indicating the lag associated with the maximum correlation value between x and y.

Author(s)

Alex J.C. Witsil

See Also

ccf

Examples

 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')

imagefx documentation built on Feb. 14, 2020, 1:07 a.m.