TimeSeriesCausality.jl

This is a Julia implementation of the Phase Slope Index and Granger Causality methods. Please refer to http://doc.ml.tu-berlin.de/causality for more information.

Outline

Functions

Phase Slope Index (PSI) estimation psi_est:

TimeSeriesCausality.psi_estFunction
psi_est(data, seglen ; segshift, eplen, freqlist, method,
        nboot, segave, subave, detrend)

calculates phase slope index (PSI)

Arguments

  • data::AbstractArray: NxM array for N data points in M channels
  • seglen::Integer: segment length (determines the frequency resolution). If defining freqlist, seglen must be the same as sampling frequency.

optional arguments

  • segshift::Integer: number of bins by which neighboring segments are shifted (default is seglen / 2)
  • eplen::Integer: length of epochs (default is number of samples)
  • freqlist::AbstractArray: a UnitRange or 2D-Array where each column is a frequency band (default is full range). Note that the DC component (0th frequency of FFT) is discarded, and freqlist shall only include integer values.
  • method::String: standard deviation estimation method (default is "jackknife")
  • subave::Bool: if true, subtract average across Cross Spectra segments (default is false)
  • segave::Bool: if true, average across Cross Spectra segments (default is true)
  • nboot::Integer: number of bootstrap resampling iterations (default is 100)
  • detrend::Bool: if true, performs a 0th-order detrend across raw segments (default is false)
  • window::Function: window function with interval length as sole necessary argument (default is Hanning)
  • verbose::Bool: if true, warnings and info logs would be echoed. (default is false)

Returns

  • psi::AbstractArray: Phase Slope Index with shape (channel, channel, frequency bands)
  • psi_std::AbstractArray: PSI estimated standard deviation with shape (channel, channel, frequency bands)
source

Granger Causality estimation granger_est:

TimeSeriesCausality.granger_estFunction
granger_est(data, seglen; order, method, verbose)

Granger's method of causal relation approximation

Arguments

  • data::AbstractArray: Nx2 array for N data points in 2 channels.
  • seglen::Integer: segment length.

optional arguments

  • method::String: standard deviation estimation method (default is "jackknife")
  • order::Int: Model order. Assumed time delay order of interest (default is n_samples / 2)
  • verbose::Bool: if true, warnings and info logs would be echoed.

Returns

  • Grind::Float64: Granger causality index
  • Grind_std::Float64: estimated standard deviation of error

Internal variables:

  • Covs: Concatenated covariance mats of different orders
  • Acoef: Design (A) matrix coefficients
  • Perr: Prediction Error
  • Σ: Measures the accuracy of the autoregressive prediction

References:

  • C. W. J. Granger (1969). Investigating causal relations by econometric models and cross-spectral methods, Econometrica, 37, 424-438.
  • M. Ding et al. (2006). Granger Causality: Basic Theory and Application to Neuroscience available online: https://arxiv.org/abs/q-bio/0608035
source

Citation

Please cite the following paper if you use the PSI code in published work:

Nolte, G., Ziehe, A., Nikulin, V., Schlögl, A., Krämer, N., Brismar, T., & Müller, K.R. (2008), Robustly Estimating the Flow Direction of Information in Complex Physical Systems, Phys. Rev. Lett., 100, 234101.

Acknowledgement

This work was funded by the German Federal Ministry of Education and Research (BMBF) in the project ALICE III under grant ref. 01IS18049B.