corr_lag: Lag correlation between two variables

View source: R/corr_lag.R

corr_lagR Documentation

Lag correlation between two variables

Description

Lag correlation between two variables

Usage

corr_lag(
  x,
  y = x,
  lag = 1,
  index = NULL,
  dates = NULL,
  doy_lims,
  verbose = FALSE
)

corr_lags(x, y, lags = -5:5, index, dates = NULL, doy_lims, ...)

find_x_lag(x, lag, index)

Arguments

x, y

A numeric vector

lag

The step of lag time

index

A numeric vector, the subscript of x, e.g. ydn

dates

Dates vector, dates of x

doy_lims

constrain index in the range of period

...

other parameters to corr_lag()

Value

  • cor: pearson correlation of lag step

  • lag:

  • positive: y is earlier;

  • negative: x is earlier.

Note

correlation needs to be adjusted because the length of observation is different

Examples

## Not run: 
# examples
x = sin(1:365)
y = x
index = 1:365
dates = seq(as.Date('2010-01-01'), as.Date('2010-12-31'), 'day')
corr_lags(x, y, index, dates, lag = 1)

## End(Not run)

kongdd/PhenoAsync documentation built on April 21, 2024, 2:36 a.m.