shuffle_segments: Shuffle MEA data (within subjects)

View source: R/rMEA_rand.R

shuffle_segmentsR Documentation

Shuffle MEA data (within subjects)

Description

This function generates fakes dyads to be used for pseudosynchrony calculations following the Ramseyer & Tschacher (2010) within-subject segment shuffling approach. Between subjects shuffling shuffle is probably more conservative, and suggested for most cases. This function is provided for replicability of older studies, and can be useful to quickly assess pseudosynchrony in single sessions, or very small samples.

Usage

shuffle_segments(mea, n_each, segSec)

Arguments

mea

a list of MEA objects (see function readMEA).

n_each

the number of random dyads to be generated from each real dyad.

segSec

the width (in seconds) of the shuffling segments.

Details

For each MEA object, the shuffling procedure first divides s1 and s2 MEA data in segments of size segSec, then shuffles them within subject (so that the new segments of s1, are the old segments of s1 in a new order). This is repeated for n_each times, before getting to the next MEA object

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 n_each * length(mea) random 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_segments(mea_normal, n_each=10, segSec=30)

summary(mea_rand)

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