cor.lag: Lag/Lead Correlation

Description Usage Arguments Examples

View source: R/cor.lag.R

Description

Calculating correlation of two vectors with lag and lead periods. The correlations are used to determine the lag or lead effect between two variables. The correlation function uses "na.or.complete" method and calculate the Pearson's correlation.

Usage

1
cor.lag(x,y,lag,lead)

Arguments

x

:the moving vector

y

:the fixed vector

lag

:number of lag periods

lead

:number of lead periods

Examples

1
cor.lag(mtcars[,1],mtcars[,2],3,3)

Example output

        lag1        lag2      lag3         0      lead1      lead2     lead3
1 -0.4568483 -0.09564063 0.3799874 -0.852162 -0.3576969 -0.1025955 0.4523748
Warning messages:
1: In cv.lag(x, i) : NAs introduced by coercion
2: In cv.lag(x, i) : NAs introduced by coercion
3: In cv.lag(x, i) : NAs introduced by coercion
4: In cv.lead(x, i) : NAs introduced by coercion
5: In cv.lead(x, i) : NAs introduced by coercion
6: In cv.lead(x, i) : NAs introduced by coercion

YRmisc documentation built on March 25, 2020, 5:13 p.m.

Related to cor.lag in YRmisc...