instantaneous_correlation_rcpp: Compute Instantaneous Correlation between Two Signals (Rcpp...

View source: R/despike.R View source: R/RcppExports.R

instantaneous_correlation_rcppR Documentation

Compute Instantaneous Correlation between Two Signals (Rcpp Version)

Description

Computes the instantaneous correlation between two signals using an exponential decay weighting function. This version uses Rcpp for improved performance.

Usage

instantaneous_correlation_rcpp(x, y, eta, offset = 0)

Arguments

x

Numeric vector. First time-series signal.

y

Numeric vector. Second time-series signal.

eta

Positive numeric value. Decay parameter for the exponential weighting function.

offset

Integer. Temporal offset between the two signals. Defaults to 0.

Value

Numeric vector of instantaneous correlation coefficients.

Examples

# Example signals
x <- sin(seq(0, 2 * pi, length.out = 100))
y <- cos(seq(0, 2 * pi, length.out = 100))
# Compute instantaneous correlation using Rcpp
rho <- instantaneous_correlation_rcpp(x, y, eta = 0.1)
# Plot the result
plot(rho, type = 'l', ylab = 'Instantaneous Correlation', xlab = 'Time')

bbuchsbaum/fmrireg documentation built on March 1, 2025, 11:20 a.m.