shuffle: Shuffle MEA data (between subjects)

View source: R/rMEA_rand.R

shuffleR Documentation

Shuffle MEA data (between subjects)

Description

This function recombines the s1 and s2 motion energy time-series between all MEA objects in the supplied list. It is typically used to compare genuine synchrony of real data with pseudosynchrony of shuffled (recombined) data.

Usage

shuffle(mea, size = "max", keepRoles = FALSE)

Arguments

mea

a list of MEA objects (see function readMEA).

size

either "max" or an integer specifying the number of combinations to be returned.

keepRoles

Boolean. If TRUE the resulting random dyad will preserve the roles, i.e. they will all have a new s1 sampled among all s1s and a new s2 sampled among all s2s. If FALSE (default), the role will be disregared.

Details

The shuffling process first creates all possible combinations between s1 and s2 of all MEA objects in the supplied list, then removes the original pairings, and finally extracts the desired numbers of dyads without replacement.

Note: all the ccf data, if present, are discarded from the shuffled objects and have to be calculated again using MEAccf

Value

an object of class MEAlist containing randomly combined dyads.

Examples

## read the first 4 minutes of the normal sample
##   (intake interviews of patients that carried on therapy)
path_normal <- system.file("extdata/normal", package = "rMEA")
mea_normal <- readMEA(path_normal, sampRate = 25, s1Col = 1, s2Col = 2,
                     s1Name = "Patient", s2Name = "Therapist",
                     idOrder = c("id","session"), idSep="_", skip=1, nrow = 6000)
mea_normal <- setGroup(mea_normal, "normal")

## Create a shuffled sample
mea_rand = shuffle(mea_normal, 50)

summary(mea_rand)

rMEA documentation built on March 18, 2022, 5:41 p.m.