R/Cal_Cross_Corr.R

Defines functions Cal_Cross_Corr

Documented in Cal_Cross_Corr

Cal_Cross_Corr <-
function(ts1, ts2, max_lag) {
  # Calculation of cross-correlation
  cc_result <- ccf(ts1, ts2, lag.max = max_lag, plot = FALSE)

  # Extracting the results
  lags <- cc_result$lag
  correlations <- cc_result$acf

  # Return the results as a data frame
  return(data.frame(lag = lags, correlation = correlations))
}

Try the ADTSA package in your browser

Any scripts or data that you put into this service are public.

ADTSA documentation built on May 29, 2024, 11:48 a.m.