View source: R/transfer_entropy.R
| transfer_entropy | R Documentation |
Function to estimate Shannon and Renyi transfer entropy between two time series x and y.
transfer_entropy( x, y, lx = 1, ly = 1, q = 0.1, entropy = "Shannon", shuffles = 100, type = "quantiles", quantiles = c(5, 95), bins = NULL, limits = NULL, nboot = 300, burn = 50, quiet = NULL, seed = NULL, na.rm = TRUE )
x |
a vector of numeric values, ordered by time.
Also allowed are |
y |
a vector of numeric values, ordered by time.
Also allowed are |
lx |
Markov order of x, i.e. the number of lagged values affecting the
current value of x. Default is |
ly |
Markov order of y, i.e. the number of lagged values affecting the
current value of y. Default is |
q |
a weighting parameter used to estimate Renyi transfer entropy,
parameter is between 0 and 1. For |
entropy |
specifies the transfer entropy measure that is estimated,
either 'Shannon' or 'Renyi'. The first character can be used
to specify the type of transfer entropy as well. Default is
|
shuffles |
the number of shuffles used to calculate the effective
transfer entropy. Default is |
type |
specifies the type of discretization applied to the observed time
series:'quantiles', 'bins' or 'limits'. Default is
|
quantiles |
specifies the quantiles of the empirical distribution of the
respective time series used for discretization.
Default is |
bins |
specifies the number of bins with equal width used for
discretization. Default is |
limits |
specifies the limits on values used for discretization.
Default is |
nboot |
the number of bootstrap replications for each direction of
the estimated transfer entropy. Default is |
burn |
the number of observations that are dropped from the beginning of
the bootstrapped Markov chain. Default is |
quiet |
if FALSE (default), the function gives feedback. |
seed |
a seed that seeds the PRNG (will internally just call set.seed),
default is |
na.rm |
if missing values should be removed (will remove the values at
the same point in the other series as well). Default is |
an object of class transfer_entropy, containing the transfer entropy
estimates in both directions, the effective transfer entropy
estimates in both directions, standard errors and p-values based on
bootstrap replications of the Markov chains under the null hypothesis
of statistical independence, an indication of statistical
significance, and quantiles of the bootstrap samples
(if nboot > 0).
coef, print.transfer_entropy
# construct two time-series
set.seed(1234567890)
n <- 500
x <- rep(0, n + 1)
y <- rep(0, n + 1)
for (i in seq(n)) {
x[i + 1] <- 0.2 * x[i] + rnorm(1, 0, 2)
y[i + 1] <- x[i] + rnorm(1, 0, 2)
}
x <- x[-1]
y <- y[-1]
# Calculate Shannon's Transfer Entropy
te_result <- transfer_entropy(x, y, nboot = 100)
te_result
summary(te_result)
# Parallel Processing using the future-package
library(future)
plan(multisession)
te_result2 <- transfer_entropy(x, y, nboot = 100)
te_result2
# revert back to sequential execution
plan(sequential)
te_result2 <- transfer_entropy(x, y, nboot = 100)
te_result2
# General set of quiet
set_quiet(TRUE)
a <- transfer_entropy(x, y, nboot = 0)
set_quiet(FALSE)
a <- transfer_entropy(x, y, nboot = 0)
# close multisession, see also ?plan
plan(sequential)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.