Random chunk resampling
#
CausalityToolsBase.causality
— Method.
causality(x, y, test::RandomSequencesTest)
Apply a causality test on random, consecutive chunks of x
and y
.
The chunk length can be fixed (an integer) or a collection of chunk lengths.
Works on any inputs x
and y
, both scalar vectors and uncertain datasets.
Example
For scalar valued vectors:
x, y = rand(100), rand(100)
# Use a cross-mapping test with default parameters (not recommended,
# make sure you understand the parameters!)
cm_test = CrossMappingTest()
# A random sequences test that applies the cross mapping test
# to 150 different random chunks of the data of lengths 80 to 90
n_realisations, chunk_lengths = 150, 80:90
rs = RandomSequences(n_realisations, chunk_lengths)
# Combine to a RandomSequencesTest
rs_test = RandomSequencesTest(cm_test, chunk_lengths)
# Compute causality statistic
causality(x, y, rs_test)
This also works on uncertain data, or any combination of scalar vectors and uncertain data:
# Some example data
N = 300
sys = ar1_unidir(c_xy = 0.8)
X, Y = example_uncertain_indexvalue_datasets(sys, N, (1, 2),
d_xval = Uniform(0.001, 0.05), d_yval = Uniform(0.001, 0.05));
# Apply cross mapping test on 100 different randomly selected chunks
# of lengths 75 to 90
r = RandomSequences(100, 75:90)
rs_test = RandomSequencesTest(CrossMappingTest(), r)
causality(X, Y, rs_test)
RandomSequencesTest
#
CausalityTools.CausalityTests.RandomSequencesTest
— Type.
RandomSequencesTest(test::CausalityTest, sequences_resampling::RandomSequences)
A causality test where the test
is applied to multiple independent draws of the datasets, where each draw from a randomly selected consecutive chunk of points.
Examples
Say we want do do a cross mapping test on a set of time series with N = 200
points. To get some ensemble statistics, we want to do an ensemble analysis on 150 randomly selected chunks of the time series with lengths ranging from N-30
to N-1
.
# A cross mapping test with default parameters (don't use default parameters in a real analysis!)
cm_test = CrossMappingTest()
# Combine with the random sequence subsamling
rtest = RandomSequencesTest(, RandomSequences(150, N-30:N-1))