Cross-correlations of two time series are computed up to a specific lag in seconds maxlag. Cross-correlation is done within segment of the time series. The size of segments segment can be chosen in seconds. Aggregation is then performed by transforming correlations to Fisher's Z, computing mean Z in each segment, then across all segments of the time series. Segment shuffling is used to create surrogate time series, on which the same computations are run. This provides effect sizes ES. SUSY provides these different synchrony measures for each twin time series: mean Z and ES of mean Z; mean absolute_Z and ES of mean absolute_Z.

susy(x, segment, Hz, maxlag=3L, permutation=FALSE,
restrict.surrogates=FALSE, surrogates.total=500)

## Arguments

x

A data.frame of numeric columns.

segment

Integer, size in seconds. Must not be smaller than 2 * maxlag, must not be larger than half the the time series (nrow(x)/2).

Hz

Integer, frames per second (sampling rate).

maxlag

Integer, maximum lag for ccf in seconds. Default 3 seconds.

permutation

Logical, default FALSE requires x to have even number of columns which are processed in pairs (1-2, 3-4, etc.). When permutation is TRUE then function computes all pairs combinations between columns provided in x (n*(n-1)/2 pairs).

restrict.surrogates

Logical, default FALSE. Restrict the number of surrogates or not.

surrogates.total

Numeric, the number of generated surrogates, default 500. Ignored when restrict.surrogates is FALSE (default).

## Details

Segments are non-overlapping, and the number of segments that fit into the time series may have a remainder (usually a few seconds at the end of the time series), which is not considered.

## Value

Object of class susy is returned. Each cross correlation pair is an element in resulting object.

plot.susy, as.data.frame.susy, print.susy

## Examples

n = 1000
data = data.frame(
var1 = runif(n, 300, 330),
var2 = runif(n, 300, 330),
var3 = runif(n, 300, 330)
)

## use only first two columns
res = susy(data[, 1:2], segment=30L, Hz=15L)
length(res)
#> [1] 1
names(res)
#> [1] "var1-var2"

## use all columns and permutation
res = susy(data, segment=30L, Hz=15L, permutation=TRUE)
length(res)
#> [1] 3
names(res)
#> [1] "var1-var2" "var1-var3" "var2-var3"

## print susy
res
#>   Var1 Var2 n(data)          Z   Z-Pseudo      SD(Z) SD(Z-Pseudo) n(lags)
#> 1 var1 var2    1000 0.03636885 0.03712315 0.01860199   0.01947570      91
#> 2 var1 var3    1000 0.03825657 0.03765609 0.02221252   0.01505695      91
#> 3 var2 var3    1000 0.03826532 0.03309453 0.01911556   0.01732719      91
#> 1 49.45055           2 -0.03873034 0.03405604 0.03906248 -0.11676612 0.04980097
#> 2 46.15385           2  0.03988063 0.03665057 0.03948971 -0.07584888 0.11584061
#> 3 59.34066           2  0.29842071 0.03850725 0.03853745  0.32482423 0.29573266
#>   meanZ(in-phase) meanZ(anti-phase) Anzahl(in-phase) Anzahl(anti-phase)
#> 1      0.02905845       -0.02732743               44                 47
#> 2      0.02156835       -0.02920355               38                 53
#> 3      0.02326072       -0.02765792               47                 44
#>        Z(noAbs) Z(Pseudo-noAbs) %>Pseudo(noAbs)   ES(noAbs)
#> 1 -6.392772e-05   -0.0031233874        57.14286  0.09800256
#> 2 -8.002099e-03   -0.0001125343        47.25275 -0.24116398
#> 3 -1.359281e-03    0.0028478785        50.54945 -0.14152443
print(res, legacy=TRUE)
#> Var1 Var2 n(data) Z Z-Pseudo SD(Z) SD(Z-Pseudo) n(lags) %>Pseudo n(Segmente) ES Z(lead1) Z(lead2) ES(lead1) ES(lead2) meanZ(in-phase) meanZ(anti-phase) Anzahl(in-phase) Anzahl(anti-phase) Z(noAbs) Z(Pseudo-noAbs) %>Pseudo(noAbs) ES(noAbs)
#> var1 var2 1000 0.03636885 0.03712315 0.01860199 0.0194757 91 49.45055 2 -0.03873034 0.03405604 0.03906248 -0.1167661 0.04980097 0.02905845 -0.02732743 44 47 -6.392772e-05 -0.003123387 57.14286 0.09800256
#> var1 var3 1000 0.03825657 0.03765609 0.02221252 0.01505695 91 46.15385 2 0.03988063 0.03665057 0.03948971 -0.07584888 0.1158406 0.02156835 -0.02920355 38 53 -0.008002099 -0.0001125343 47.25275 -0.241164
#> var2 var3 1000 0.03826532 0.03309453 0.01911556 0.01732719 91 59.34066 2 0.2984207 0.03850725 0.03853745 0.3248242 0.2957327 0.02326072 -0.02765792 47 44 -0.001359281 0.002847878 50.54945 -0.1415244

## plot susy
plot(res)
plot(res, type=1:2)