calculate_lagged_correlation

calculate_lagged_correlation(
  x,
  y,
  time1,
  time2,
  time_tol = 1,
  step = 1/60,
  min_matched_sample = 10,
  progressbar = TRUE,
  all_idx = NULL,
  threads = 10,
  cor_method = c("spearman", "pearson")
)

Arguments

x

Time-series data 1. A numeric vector.

y

Time-series data 2. A numeric vector.

time1

Time-series data 1. A time vector (POSIXct).

time2

Time-series data 2. A time vector (POSIXct).

time_tol

Time tolerance to match time-series 1 and time-series data 2. Unit is hour.

step

Step to calculate lagged correlation.

min_matched_sample

Minimum matched sample numner for one lagged correlation.

progressbar

progressbar

all_idx

all_idx

threads

threads number

cor_method

spearman or pearson.

Value

A lagged_cor class object.

Author

Xiaotao Shen shenxt1990@outlook.com

Examples

if (FALSE) {
data("heart_data", package = "laggedcor")
data("step_data", package = "laggedcor")

dim(heart_data)
dim(step_data)

x = step_data$step
time1 = step_data$time

y = heart_data$heart
time2 = heart_data$time

object =
  calculate_lagged_correlation(
    x = x,
    y = y,
    time1 = time1,
    time2 = time2,
    time_tol = 0.1,
    step = 1 / 60,
    min_matched_sample = 10,
    progressbar = TRUE,
    threads = 5,
    cor_method = "spearman"
  )
object
}