Title: | Surrogate Synchrony |
---|---|
Description: | Computes synchrony as windowed cross-correlation based on two-dimensional time series in a text file you can upload. 'SUSY' works as described in Tschacher & Meier (2020) <doi:10.1080/10503307.2019.1612114>. |
Authors: | Wolfgang Tschacher [aut, cre], David Tschacher [ctb], Jan Gorecki [ctb] |
Maintainer: | Wolfgang Tschacher <[email protected]> |
License: | GPL-2 |
Version: | 0.1.1 |
Built: | 2024-11-16 04:34:11 UTC |
Source: | https://github.com/wtschacher/susy |
Turns susy
class object into a data.frame
.
## S3 method for class 'susy' as.data.frame(x, row.names=NULL, optional=FALSE, corr.no.abs=TRUE, ...)
## S3 method for class 'susy' as.data.frame(x, row.names=NULL, optional=FALSE, corr.no.abs=TRUE, ...)
x |
A |
row.names |
Ignored, only for consistency to generic |
optional |
Ignored, only for consistency to generic |
corr.no.abs |
Logical, defaults to |
... |
Ignored. |
Returns data.frame
.
n = 1000 data = data.frame( var1 = runif(n, 300, 330), var2 = runif(n, 300, 330) ) res = susy(data, segment=30L, Hz=15L) as.data.frame(res)
n = 1000 data = data.frame( var1 = runif(n, 300, 330), var2 = runif(n, 300, 330) ) res = susy(data, segment=30L, Hz=15L) as.data.frame(res)
Generate plot(s) for a susy
object.
## S3 method for class 'susy' plot(x, type=c(4, 5), ...)
## S3 method for class 'susy' plot(x, type=c(4, 5), ...)
x |
A |
type |
Numeric, specifies the types of plot, defaults to
|
... |
Ignored. |
Method can generate multiple types of plots by providing numeric vector to type
argument. Note it will generate plots for each pair (cross computation) in x
, so the final number of plots is length(x) * length(type)
.
Returns NULL
invisibly. Generate plot(s) as a side effect.
n = 1000 data = data.frame( var1 = runif(n, 300, 330), var2 = runif(n, 300, 330), var3 = runif(n, 300, 330) ) res = susy(data, segment=30L, Hz=15L, permutation=TRUE) plot(res, type=c(3,5))
n = 1000 data = data.frame( var1 = runif(n, 300, 330), var2 = runif(n, 300, 330), var3 = runif(n, 300, 330) ) res = susy(data, segment=30L, Hz=15L, permutation=TRUE) plot(res, type=c(3,5))
Prints information about an susy
object.
## S3 method for class 'susy' print(x, corr.no.abs=TRUE, legacy=FALSE, ...)
## S3 method for class 'susy' print(x, corr.no.abs=TRUE, legacy=FALSE, ...)
x |
A |
corr.no.abs |
Logical, defaults to |
legacy |
Logical, defaults to |
... |
Extra arguments passed to |
Returns x
invisibly. Display output to console as a side effect.
n = 1000 data = data.frame( var1 = runif(n, 300, 330), var2 = runif(n, 300, 330) ) res = susy(data, segment=30L, Hz=15L) res print(res, corr.no.abs=FALSE) print(res, digits=4) print(res, legacy=TRUE)
n = 1000 data = data.frame( var1 = runif(n, 300, 330), var2 = runif(n, 300, 330) ) res = susy(data, segment=30L, Hz=15L) res print(res, corr.no.abs=FALSE) print(res, digits=4) print(res, legacy=TRUE)
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)
susy(x, segment, Hz, maxlag=3L, permutation=FALSE, restrict.surrogates=FALSE, surrogates.total=500)
x |
A data.frame of numeric columns. |
segment |
Integer, size in seconds. Must not be smaller than |
Hz |
Integer, frames per second (sampling rate). |
maxlag |
Integer, maximum lag for |
permutation |
Logical, default |
restrict.surrogates |
Logical, default |
surrogates.total |
Numeric, the number of generated surrogates, default |
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.
Object of class susy
is returned. Each cross correlation pair is an element in resulting object.
plot.susy
, as.data.frame.susy
, print.susy
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) names(res) ## use all columns and permutation res = susy(data, segment=30L, Hz=15L, permutation=TRUE) length(res) names(res) ## print susy res print(res, legacy=TRUE) ## plot susy plot(res) plot(res, type=1:2)
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) names(res) ## use all columns and permutation res = susy(data, segment=30L, Hz=15L, permutation=TRUE) length(res) names(res) ## print susy res print(res, legacy=TRUE) ## plot susy plot(res) plot(res, type=1:2)