instantaneous_correlation: Compute Instantaneous Correlation between Two Signals

View source: R/despike.R

instantaneous_correlationR Documentation

Compute Instantaneous Correlation between Two Signals

Description

Computes the instantaneous correlation between two signals using an exponential decay weighting function, allowing for efficient recursive computation.

Usage

instantaneous_correlation(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
rho <- instantaneous_correlation(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.