MEAccf {rMEA} | R Documentation |
Moving-windows lagged cross-correlation routine for MEA
objects
Description
This function analyzes a bivariate MEA signal represented by two time-series (subject 1 "s1", subject 2 "s2") resulting from a dyadic interaction. MEAccf performs windowed cross-correlations with specified increments. The cross-correlation analysis is repeated for each lag step, with discrete increments of 1 sample in both directions.
Usage
MEAccf(mea, lagSec, winSec, incSec, r2Z = T, ABS = T)
Arguments
mea |
an object of class |
lagSec |
an integer specifying the maximum number of lags (in seconds) for which the time-series will be shifted forwards and backwards. |
winSec |
an integer specifying the cross-correlation window size (in seconds). |
incSec |
an integer specifying the step size (in seconds) between successive windows. Values lower than |
r2Z |
logical. The default value TRUE applies Fisher's r to Z transformation (inverse hyperbolic tangent function) to all computed correlations. |
ABS |
logical. The default value TRUE transforms the (Fisher's Z-transformed) correlations to absolute values. |
Details
The choice of lagSec
depends on the type of synchronization expected from the specific interaction. In the literature, lags of ±5 seconds have been reported by multiple authors.
Function MEAlagplot
can be used for visual inspection of the appropriateness of the chosen lag.
The choice of winSec
represents the temporal resolution of the analysis.
The combination of incSec
and winSec
settings has a big impact on the results. These parameters should be chosen carefully, guided by theoretical and empirical considerations.
If r2Z
is TRUE, values of Fisher's Z are constrained to an upper bound of 10.
Using absolute values (ABS
) treats positive and negative cross-correlations as equal. The underlying assumption is that both simultaneous movement (positive correlation) and when
one subject accelerates and the other decelerates (negative correlation), are both signs of interrelatedness and should thus contribute equally to overall synchrony.
Value
The function returns a copy of the mea
object in which the ccf
and ccfRes
objects are populated. mea$ccf
includes the complete lagged cross-correlation table
for each window and each lag of S1 and S2 MEA signals. mea$ccfRes
contains various aggregate values, typically used in research:
lag_zero: a numeric vector containing for each window, the non-lagged cross-correlation value.
all_lags: a numeric vector containing for each window, the average across all lags.
s1_lead/s2_lead: a numeric vector containing for each window, the average of positive/negative lags, summing up the strength of S1/S2 in "leading" the synchronization.
s1_lead_0/s2_lead_0: the same as s1_lead/s2_lead, but including lag_zero values in the average.
bestLag: for each window, the lag value (in seconds) that has the highest correlation value.
grandAver: a single numeric value of the grand-average of the whole cross-correlation table.
winTimes: a data frame containing the start and end times of each window in the format hh:mm:ss
Examples
## read a single file
path_normal <- system.file("extdata/normal/200_01.txt", package = "rMEA")
mea_normal <- readMEA(path_normal, sampRate = 25, s1Col = 1, s2Col = 2,
s1Name = "Patient", s2Name = "Therapist", skip=1,
idOrder = c("id","session"), idSep="_")
## perform ccf analysis
mea_ccf = MEAccf(mea_normal, lagSec = 5, winSec = 60, incSec = 30, r2Z = TRUE, ABS = TRUE)
summary(mea_ccf)
##extract ccf values
res <- getCCF(mea_ccf, type="grandAver")
print(res)
#visualize the analysis results for the first file
MEAheatmap(mea_ccf[[1]])