diff --git a/LICENSE.md b/LICENSE.md index b1c412537..2feed387e 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -The CausalityTools.jl package is licensed under the MIT "Expat" License: +The Associations.jl package (previously called CausalityTools.jl) is licensed under the MIT "Expat" License: > Copyright (c) 2018: Kristian Agasøster Haaga. > diff --git a/Project.toml b/Project.toml index ea81bf9d8..c1231528d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,8 +1,8 @@ -name = "CausalityTools" -uuid = "5520caf5-2dd7-5c5d-bfcb-a00e56ac49f7" +name = "Associations" +uuid = "614afb3a-e278-4863-8805-9959372b9ec2" authors = ["Kristian Agasøster Haaga ", "Tor Einar Møller ", "George Datseris "] -repo = "https://github.com/kahaaga/CausalityTools.jl.git" -version = "3.0.0" +repo = "https://github.com/kahaaga/Associations.jl.git" +version = "4.0.0" [deps] Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" diff --git a/README.md b/README.md index 00641d835..e83c836e2 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ -# CausalityTools +# Associations -[![CI](https://github.com/juliadynamics/CausalityTools.jl/workflows/CI/badge.svg)](https://github.com/JuliaDynamics/CausalityTools.jl/actions) -[![](https://img.shields.io/badge/docs-latest_tagged-blue.svg)](https://juliadynamics.github.io/CausalityTools.jl/stable/) -[![](https://img.shields.io/badge/docs-dev_(master)-blue.svg)](https://juliadynamics.github.io/CausalityTools.jl/dev/) -[![codecov](https://codecov.io/gh/JuliaDynamics/CausalityTools.jl/branch/master/graph/badge.svg?token=0b71n6x6AP)](https://codecov.io/gh/JuliaDynamics/CausalityTools.jl) +[![CI](https://github.com/juliadynamics/Associations.jl/workflows/CI/badge.svg)](https://github.com/JuliaDynamics/Associations.jl/actions) +[![](https://img.shields.io/badge/docs-latest_tagged-blue.svg)](https://juliadynamics.github.io/Associations.jl/stable/) +[![](https://img.shields.io/badge/docs-dev_(master)-blue.svg)](https://juliadynamics.github.io/Associations.jl/dev/) +[![codecov](https://codecov.io/gh/JuliaDynamics/Associations.jl/branch/master/graph/badge.svg?token=0b71n6x6AP)](https://codecov.io/gh/JuliaDynamics/Associations.jl) [![DOI](https://zenodo.org/badge/135443027.svg)](https://zenodo.org/badge/latestdoi/135443027) -CausalityTools.jl is a package for quantifying associations, independence testing and causal inference. +Associations.jl is a package for quantifying associations, independence testing and causal inference. All further information is provided in the -[documentation](https://juliadynamics.github.io/CausalityTools.jl/dev), which you can either +[documentation](https://juliadynamics.github.io/Associations.jl/dev), which you can either find online or build locally by running the `docs/make.jl` file. ## Key features @@ -31,4 +31,6 @@ we also offer ## Installation -To install the package, run `import Pkg; Pkg.add("CausalityTools")`. +To install the package, run `import Pkg; Pkg.add("Associations")`. + +*Previously, this package was called CausalityTools.jl*. \ No newline at end of file diff --git a/docs/Project.toml b/docs/Project.toml index 67bd22a04..8a97c9016 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,6 +1,5 @@ [deps] CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" -CausalityTools = "5520caf5-2dd7-5c5d-bfcb-a00e56ac49f7" ComplexityMeasures = "ab4b797d-85ee-42ba-b621-05d793b346a2" DelayEmbeddings = "5732040d-69e3-5649-938a-b6b4f237613f" Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7" diff --git a/docs/make.jl b/docs/make.jl index 0967aabf2..37f471c1c 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -6,12 +6,12 @@ using DocumenterInterLinks import Downloads # Packages used in the doc build. -using CausalityTools +using Associations using ComplexityMeasures using StateSpaceSets pages = [ - "CausalityTools.jl" => "index.md", + "Associations.jl" => "index.md", "Core API reference" => [ "Association measures" => "associations.md", "Independence" => "independence.md", @@ -43,7 +43,7 @@ bibliography = CitationBibliography( style=:authoryear ) -build_docs_with_style(pages, CausalityTools, ComplexityMeasures, StateSpaceSets; +build_docs_with_style(pages, Associations, ComplexityMeasures, StateSpaceSets; expandfirst = ["index.md"], bib = bibliography, pages = pages, diff --git a/docs/src/api/counts_and_probabilities_api.md b/docs/src/api/counts_and_probabilities_api.md index 4c1384d2c..794e0cdfe 100644 --- a/docs/src/api/counts_and_probabilities_api.md +++ b/docs/src/api/counts_and_probabilities_api.md @@ -1,17 +1,21 @@ +```@meta +CollapsedDocStrings = true +``` + # [Multivariate counts and probabilities API](@id counts_and_probabilities_api) -For counting and probabilities, CausalityTools.jl extends the single-variable machinery +For counting and probabilities, Associations.jl extends the single-variable machinery in ComplexityMeasures.jl to multiple variables. ```@docs -CausalityTools.Counts -CausalityTools.counts(::OutcomeSpace) +Associations.Counts +Associations.counts(::OutcomeSpace) ``` ```@docs -CausalityTools.Probabilities -CausalityTools.probabilities(::OutcomeSpace) +Associations.Probabilities +Associations.probabilities(::OutcomeSpace) ``` The utility function [`marginal`](@ref) is also useful. @@ -26,7 +30,7 @@ Estimating multivariate counts (contingency matrices) and PMFs is simple. If the we can use [`UniqueElements`](@ref) to simply count the number of occurrences. ```@example counts_probs_tutorial -using CausalityTools +using Associations n = 50 # the number of samples must be the same for each input variable x = rand(["dog", "cat", "snake"], n) y = rand(1:4, n) @@ -46,7 +50,7 @@ For numerical data, we can estimate both counts and probabilities using [`Codify with any count-based [`OutcomeSpace`](@ref). ```@example counts_probs_tutorial -using CausalityTools +using Associations x, y = rand(100), rand(100) discretization = CodifyVariables(BubbleSortSwaps(m = 4)) probabilities(discretization, x, y) @@ -55,7 +59,7 @@ probabilities(discretization, x, y) For more fine-grained control, we can use [`CodifyPoints`](@ref) with one or several [`Encoding`](@ref)s. ```@example counts_probs_tutorial -using CausalityTools +using Associations x, y = StateSpaceSet(rand(1000, 2)), StateSpaceSet(rand(1000, 3)) # min/max of the `rand` call is 0 and 1 diff --git a/docs/src/api/cross_map_api.md b/docs/src/api/cross_map_api.md index 5ef4df070..469280bb7 100644 --- a/docs/src/api/cross_map_api.md +++ b/docs/src/api/cross_map_api.md @@ -40,7 +40,7 @@ Let's reproduce figure 3A too, focusing only on [`ConvergentCrossMapping`](@ref) For this example, they use a bidirectional system with asymmetrical coupling strength. ```@example MAIN_CCM -using CausalityTools +using Associations using Statistics using LabelledArrays using StaticArrays @@ -201,7 +201,7 @@ slightly different embedding. ```@example MAIN_CCM -using CausalityTools +using Associations using Statistics using LabelledArrays using StaticArrays @@ -267,7 +267,7 @@ variables ``X`` and ``Y``, where ``X`` drives ``Y``. After we have computed the PAI in both directions, we define a measure of directionality as the difference between PAI in the ``X \to Y`` direction and in the ``Y \to X`` direction, so that if ``X`` drives ``Y``, then ``\Delta < 0``. ```@example MAIN_CCM -using CausalityTools +using Associations using LabelledArrays using StaticArrays using DynamicalSystemsBase diff --git a/docs/src/api/discretization_counts_probs_api.md b/docs/src/api/discretization_counts_probs_api.md index 9bab7ea3f..d74770b5c 100644 --- a/docs/src/api/discretization_counts_probs_api.md +++ b/docs/src/api/discretization_counts_probs_api.md @@ -12,7 +12,7 @@ When discretizing, what happens is that we "encode" input data into an intermedi - Once a dataset has been encoded into integers, we can estimate [`Counts`](@ref) or [`Probabilities`](@ref) ([tutorial](@ref tutorial_probabilities)). - Once probabilities have been estimated, one can use these to estimate [`MultivariateInformationMeasure`](@ref) ([tutorial](@ref tutorial_infomeasures)). - The following functions and types are used by CausalityTools.jl to perform discretization of input data. + The following functions and types are used by Associations.jl to perform discretization of input data. ```@docs Discretization @@ -21,7 +21,7 @@ CodifyPoints codify ``` -In summary, the two main ways of discretizing data in CausalityTools are as follows. +In summary, the two main ways of discretizing data in Associations are as follows. - The [`CodifyPoints`](@ref) discretization scheme encodes input data on a point-by-point basis by applying some [`Encoding`](@ref) to each point. @@ -66,7 +66,7 @@ We'll here use the [`OrdinalPatternEncoding`](@ref) with differing parameter `m` multiple [`StateSpaceSet`](@ref) of differing dimensions. ```@example example_encode_points -using CausalityTools +using Associations using StateSpaceSets using Random; rng = Xoshiro(1234) @@ -128,7 +128,7 @@ Some [`OutcomeSpace`](@ref)s dictate a sliding window which has the width of one when used with [`CodifyVariables`](@ref). [`ValueBinning`](@ref) is such an outcome space. ```@example example_encode_vars -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, 100) @@ -150,7 +150,7 @@ end of each input variable are lost. For example, with [`OrdinalPatterns`](@ref) of encoded points decrease with the embedding parameter `m`. ```@example example_encode_vars -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, 100) @@ -163,7 +163,7 @@ the same outcome space, as long as the operation will result in the *same* numbe data points for each column. ```@example example_encode_vars -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, 100) diff --git a/docs/src/api/information_multivariate_api.md b/docs/src/api/information_multivariate_api.md index 8c5065683..1d79b3185 100644 --- a/docs/src/api/information_multivariate_api.md +++ b/docs/src/api/information_multivariate_api.md @@ -60,7 +60,7 @@ Amplitude ## [A small tutorial](@id tutorial_infomeasures) -CausalityTools.jl extends the single-variate information API in +Associations.jl extends the single-variate information API in [ComplexityMeasures.jl](https://github.com/JuliaDynamics/ComplexityMeasures.jl) to information measures of multiple variables. @@ -115,7 +115,7 @@ expressed as a function of a joint pmf, we can use the [`JointProbabilities`](@r estimator. ```@example INFO_TUTORIAL -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x, y = rand(rng, 1000), rand(rng, 1000) @@ -143,7 +143,7 @@ they are functions of a joint pmf, and can therefore also be estimated using the with 3 bins along each dimension to discretize the data. ```@example INFO_TUTORIAL -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x, y = randn(rng, 1000), randn(rng, 1000) @@ -161,7 +161,7 @@ entropies are functionals of a joint pmf, so we can still use the based discretization. ```@example INFO_TUTORIAL -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x, y = randn(rng, 1000), randn(rng, 1000) @@ -179,7 +179,7 @@ example, one can use dedicated [`MutualInformationEstimator`](@ref)s such as [`KraskovStögbauerGrassberger2`](@ref) or [`GaussianMI`](@ref): ```@example INFO_TUTORIAL -using CausalityTools +using Associations using StateSpaceSets # We'll construct two state space sets, to illustrate how we can discretize # multidimensional inputs using `CodifyPoints`. @@ -228,7 +228,7 @@ with any count-based [`OutcomeSpace`](@ref). Here, we'll estimate [`MIShannon`]( one type of encoding for the first variable, and another type of encoding for the second variable. ```@example counts_probs_tutorial -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x, y = rand(rng, 100), rand(rng, 100) @@ -248,7 +248,7 @@ For more fine-grained control than [`CodifyVariables`](@ref) can offer, we can u data by discretizing each input variable in arbitrary ways. ```@example counts_probs_tutorial -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x, y = StateSpaceSet(rand(rng, 1000, 2)), StateSpaceSet(rand(rng, 1000, 3)) diff --git a/docs/src/assets/logo-dark.png b/docs/src/assets/logo-dark.png deleted file mode 100644 index b187efd64..000000000 Binary files a/docs/src/assets/logo-dark.png and /dev/null differ diff --git a/docs/src/assets/logo-large.png b/docs/src/assets/logo-large.png deleted file mode 100644 index 3be08eec6..000000000 Binary files a/docs/src/assets/logo-large.png and /dev/null differ diff --git a/docs/src/assets/logo.png b/docs/src/assets/logo.png deleted file mode 100644 index 052a9c34a..000000000 Binary files a/docs/src/assets/logo.png and /dev/null differ diff --git a/docs/src/associations.md b/docs/src/associations.md index 6654065f9..0d6a729fd 100644 --- a/docs/src/associations.md +++ b/docs/src/associations.md @@ -5,7 +5,7 @@ CollapsedDocStrings = true # [Associations](@id association_measures) ## Association API -The most basic components of CausalityTools.jl are a collection of statistics that in some manner quantify the "association" between input datasets. Precisely what is meant by "association" depends on the measure, and precisely what is meant by "quantify" depends on the *estimator* of that measure. We formalize this notion below with the [`association`](@ref) +The most basic components of Associations.jl are a collection of statistics that in some manner quantify the "association" between input datasets. Precisely what is meant by "association" depends on the measure, and precisely what is meant by "quantify" depends on the *estimator* of that measure. We formalize this notion below with the [`association`](@ref) function, which dispatches on [`AssociationMeasureEstimator`](@ref) and [`AssociationMeasure`](@ref). @@ -18,7 +18,7 @@ AssociationMeasureEstimator Here are some examples of how to use [`association`](@ref). ```@repl -using CausalityTools +using Associations x, y, z = rand(1000), rand(1000), rand(1000); association(LMeasure(), x, y) association(DistanceCorrelation(), x, y) @@ -123,7 +123,7 @@ concept of "cross mapping", which has appeared in many contexts in the literatur and gained huge popularity with [Sugihara2012](@citet)'s on *convergent cross mapping*. Since their paper, several cross mapping methods and frameworks have emerged in the -literature. In CausalityTools.jl, we provide a unified interface for using these cross +literature. In Associations.jl, we provide a unified interface for using these cross mapping methods. ```@docs diff --git a/docs/src/examples/examples_associations.md b/docs/src/examples/examples_associations.md index b6e2a2358..218cb6bc4 100644 --- a/docs/src/examples/examples_associations.md +++ b/docs/src/examples/examples_associations.md @@ -5,7 +5,7 @@ ### [From precomputed probabilities](@id example_HellingerDistance_precomputed_probabilities) ```@example example_HellingerDistance -using CausalityTools +using Associations # From pre-computed PMFs p1 = Probabilities([0.1, 0.5, 0.2, 0.2]) p2 = Probabilities([0.3, 0.3, 0.2, 0.2]) @@ -17,7 +17,7 @@ association(HellingerDistance(), p1, p2) We expect the Hellinger distance between two uncorrelated variables to be close to zero. ```@example example_HellingerDistance -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) n = 100000 x, y = rand(rng, n), rand(rng, n) @@ -30,7 +30,7 @@ div_hd = association(est, x, y) # pretty close to zero ### [From precomputed probabilities](@id example_KLDivergence_precomputed_probabilities) ```@example example_KLDivergence -using CausalityTools +using Associations # From pre-computed PMFs p1 = Probabilities([0.1, 0.5, 0.2, 0.2]) p2 = Probabilities([0.3, 0.3, 0.2, 0.2]) @@ -42,7 +42,7 @@ association(KLDivergence(), p1, p2) We expect the [`KLDivergence`](@ref) between two uncorrelated variables to be close to zero. ```@example example_KLDivergence -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) n = 100000 x, y = rand(rng, n), rand(rng, n) @@ -56,7 +56,7 @@ div_hd = association(est, x, y) # pretty close to zero ### [From precomputed probabilities](@id example_RenyiDivergence_precomputed_probabilities) ```@example example_RenyiDivergence -using CausalityTools +using Associations # From pre-computed PMFs p1 = Probabilities([0.1, 0.5, 0.2, 0.2]) p2 = Probabilities([0.3, 0.3, 0.2, 0.2]) @@ -68,7 +68,7 @@ association(RenyiDivergence(), p1, p2) We expect the [`RenyiDivergence`](@ref) between two uncorrelated variables to be close to zero. ```@example example_RenyiDivergence -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) n = 100000 x, y = rand(rng, n), rand(rng, n) @@ -82,7 +82,7 @@ div_hd = association(est, x, y) # pretty close to zero ### [From precomputed probabilities](@id example_VariationDistance_precomputed_probabilities) ```@example example_VariationDistance -using CausalityTools +using Associations # From pre-computed PMFs p1 = Probabilities([0.1, 0.5, 0.2, 0.2]) p2 = Probabilities([0.3, 0.3, 0.2, 0.2]) @@ -94,7 +94,7 @@ association(VariationDistance(), p1, p2) We expect the [`VariationDistance`](@ref) between two uncorrelated variables to be close to zero. ```@example example_VariationDistance -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) n = 100000 x, y = rand(rng, n), rand(rng, n) @@ -107,7 +107,7 @@ div_hd = association(est, x, y) # pretty close to zero ### [[`JointProbabilities`](@ref) with [`Dispersion`](@ref)](@id example_JointEntropyShannon_Dispersion) ```@example example_JointEntropyShannon -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x, y = rand(rng, 100), rand(rng, 100) measure = JointEntropyShannon() @@ -121,7 +121,7 @@ association(est, x, y) ### [[`JointProbabilities`](@ref) with [`OrdinalPatterns`](@ref)](@id example_JointEntropyTsallis_OrdinalPatterns) ```@example example_JointEntropyTsallis -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x, y = rand(rng, 100), rand(rng, 100) measure = JointEntropyTsallis() @@ -136,7 +136,7 @@ association(est, x, y) ### [[`JointProbabilities`](@ref) with [`OrdinalPatterns`](@ref)](@id example_JointEntropyRenyi_ValueBinning) ```@example example_JointEntropyRenyi -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x, y = rand(rng, 100), rand(rng, 100) measure = JointEntropyRenyi(q = 0.5) @@ -155,7 +155,7 @@ transpose their example. Then their `X` is in the first dimension of our table ( columns) and their `Y` is our second dimension (rows). ```@example ce_contingency_table -using CausalityTools +using Associations freqs_yx = [1//8 1//16 1//32 1//32; 1//16 1//8 1//32 1//32; 1//16 1//16 1//16 1//16; @@ -201,7 +201,7 @@ Let's first demonstrate on some categorical data. For that, we must use [`UniqueElements`](@ref) as the discretization (i.e. just count unique elements). ```@example example_ConditionalEntropyShannon_JointProbabilities_CodifyVariables_UniqueElements -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) n = 1000 rating = rand(rng, 1:6, n) @@ -215,7 +215,7 @@ association(est, rating, movie) ### [[`JointProbabilities`](@ref) + [`CodifyPoints`](@ref) + [`UniqueElementsEncoding`](@ref)](@id example_ConditionalEntropyShannon_JointProbabilities_CodifyPoints_UniqueElementsEncoding) ```@example example_ConditionalEntropyShannon_JointProbabilities_CodifyPoints_UniqueElementsEncoding -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x, y, z = rand(rng, 1:5, 100), rand(rng, 1:5, 100), rand(rng, 1:3, 100) X = StateSpaceSet(x, z) @@ -232,7 +232,7 @@ association(est, X, Y) We'll here repeat the analysis we did for [`ConditionalEntropyShannon`](@ref) above. ```@example example_ConditionalEntropyTsallisAbe_JointProbabilities_CodifyVariables_UniqueElements -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) n = 1000 rating = rand(rng, 1:6, n) @@ -246,7 +246,7 @@ association(est, rating, movie) ### [[`JointProbabilities`](@ref) + [`CodifyPoints`](@ref) + [`UniqueElementsEncoding`](@ref)](@id example_ConditionalEntropyTsallisAbe_JointProbabilities_CodifyPoints_UniqueElementsEncoding) ```@example example_ConditionalEntropyTsallisAbe_JointProbabilities_CodifyPoints_UniqueElementsEncoding -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x, y, z = rand(rng, 1:5, 100), rand(rng, 1:5, 100), rand(rng, 1:3, 100) X = StateSpaceSet(x, z) @@ -264,7 +264,7 @@ association(est, X, Y) We'll here repeat the analysis we did for [`ConditionalEntropyShannon`](@ref) and [`ConditionalEntropyTsallisAbe`](@ref) above. ```@example example_ConditionalEntropyTsallisFuruichi_JointProbabilities_CodifyVariables_UniqueElements -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) n = 1000 rating = rand(rng, 1:6, n) @@ -278,7 +278,7 @@ association(est, rating, movie) ### [[`JointProbabilities`](@ref) + [`CodifyPoints`](@ref) + [`UniqueElementsEncoding`](@ref)](@id example_ConditionalEntropyTsallisFuruichi_JointProbabilities_CodifyPoints_UniqueElementsEncoding) ```@example example_ConditionalEntropyTsallisFuruichi_JointProbabilities_CodifyPoints_UniqueElementsEncoding -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x, y, z = rand(rng, 1:5, 100), rand(rng, 1:5, 100), rand(rng, 1:3, 100) X = StateSpaceSet(x, z) @@ -294,7 +294,7 @@ association(est, X, Y) ### [[`JointProbabilities`](@ref) + [`ValueBinning`](@ref)](@id example_MIShannon_JointProbabilities_ValueBinning) ```@example mi_demonstration -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x = rand(rng, 1000) y = rand(rng, 1000) @@ -311,7 +311,7 @@ For example, let's compare the Shannon mutual information between the preference of a population sample with regards to different foods. ```@example mi_demonstration -using CausalityTools +using Associations n = 1000 preferences = rand(["neutral", "like it", "hate it"], n); random_foods = rand(["water", "flour", "bananas", "booze", "potatoes", "beans", "soup"], n) @@ -332,12 +332,12 @@ association(est, preferences, biased_foods), association(est, preferences, rando ### [Dedicated [`GaussianMI`](@ref) estimator](@id example_MIShannon_GaussianMI) ```@example mi_demonstration -using CausalityTools +using Associations using Distributions using Statistics n = 1000 -using CausalityTools +using Associations x = randn(1000) y = rand(1000) .+ x association(GaussianMI(MIShannon()), x, y) # defaults to `MIShannon()` @@ -346,7 +346,7 @@ association(GaussianMI(MIShannon()), x, y) # defaults to `MIShannon()` ### [Dedicated [`KraskovStögbauerGrassberger1`](@ref) estimator](@id example_MIShannon_KSG1) ```@example mi_demonstration -using CausalityTools +using Associations x, y = rand(1000), rand(1000) association(KSG1(MIShannon(); k = 5), x, y) ``` @@ -354,7 +354,7 @@ association(KSG1(MIShannon(); k = 5), x, y) ### [Dedicated [`KraskovStögbauerGrassberger2`](@ref) estimator](@id example_MIShannon_KSG2) ```@example mi_demonstration -using CausalityTools +using Associations x, y = rand(1000), rand(1000) association(KSG2(MIShannon(); k = 5), x, y) ``` @@ -362,7 +362,7 @@ association(KSG2(MIShannon(); k = 5), x, y) ### [Dedicated [`GaoKannanOhViswanath`](@ref) estimator](@id example_MIShannon_GaoKannanOhViswanath) ```@example mi_demonstration -using CausalityTools +using Associations x, y = rand(1000), rand(1000) association(GaoKannanOhViswanath(MIShannon(); k = 10), x, y) ``` @@ -373,7 +373,7 @@ We can compute [`MIShannon`](@ref) by naively applying a [`DifferentialInfoEstim Note that this doesn't apply any bias correction. ```@example mi_demonstration -using CausalityTools +using Associations x, y = rand(1000), rand(1000) association(EntropyDecomposition(MIShannon(), Kraskov(k = 3)), x, y) ``` @@ -385,7 +385,7 @@ We can also compute [`MIShannon`](@ref) by naively applying a [`DiscreteInfoEsti Note that this doesn't apply any bias correction. ```@example mi_demonstration -using CausalityTools +using Associations x, y = rand(1000), rand(1000) disc = CodifyVariables(BubbleSortSwaps(m=5)) hest = PlugIn(Shannon()) @@ -400,7 +400,7 @@ Here, we use [`CodifyVariables`](@ref) with [`ValueBinning`](@ref) bin the data and compute discrete Shannon mutual information. ```@example mi_demonstration -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x = rand(rng, 50) y = rand(rng, 50) @@ -424,7 +424,7 @@ curves corresponding to different time series length. We only show two single cu one for the [`KraskovStögbauerGrassberger1`](@ref) estimator and one for the [`KraskovStögbauerGrassberger2`](@ref) estimator*. ```@example ex_mutualinfo -using CausalityTools +using Associations using LinearAlgebra: det using Distributions: MvNormal using StateSpaceSets: StateSpaceSet @@ -475,7 +475,7 @@ diverges from the true value for these data, the [`GaoKannanOhViswanath`](@ref) converges to the true value. ```@example ex_mutualinfo -using CausalityTools +using Associations using Statistics using StateSpaceSets: StateSpaceSet using Statistics: mean @@ -553,7 +553,7 @@ fig Let's compare the performance of a subset of the implemented mutual information estimators. We'll use example data from Lord et al., where the analytical mutual information is known. ```@example ex_mutualinfo -using CausalityTools +using Associations using LinearAlgebra: det using StateSpaceSets: StateSpaceSet using Distributions: MvNormal @@ -786,7 +786,7 @@ We see that the [`Lord`](@ref) estimator, which estimates local volume elements with the [`UniqueElements`](@ref) outcome space. ```@example example_mirenyijizba -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, ["a", "b", "c"], 200); y = rand(rng, ["hello", "yoyo", "heyhey"], 200); @@ -801,7 +801,7 @@ in combination with any [`DifferentialInfoEstimator`](@ref) capable of estimatin [`Renyi`](@ref) entropy. ```@example example_MIRenyiJizba -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = randn(rng, 50); y = randn(rng, 50); def = MIRenyiJizba() @@ -817,7 +817,7 @@ in combination with any [`DiscreteInfoEstimator`](@ref) capable of estimating di ```@example example_MIRenyiJizba -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = randn(rng, 50); y = randn(rng, 50); def = MIRenyiJizba() @@ -835,7 +835,7 @@ in combination with any [`CodifyVariables`](@ref) or [`CodifyPoints`](@ref) disc ### [[`JointProbabilities`](@ref) + [`UniqueElements`](@ref)](@id example_MIRenyiSarbu_JointProbabilities_UniqueElements) ```@example example_MIRenyiSarbu -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, ["a", "b", "c"], 200) y = rand(rng, ["hello", "yoyo", "heyhey"], 200) @@ -847,7 +847,7 @@ association(est, x, y) ### [[`JointProbabilities`](@ref) + [`CosineSimilarityBinning`](@ref)](@id example_MIRenyiSarbu_JointProbabilities_CosineSimilarityBinning) ```@example example_MIRenyiSarbu -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, 200) y = rand(rng, 200) @@ -864,7 +864,7 @@ association(est, x, y) in combination with any [`CodifyVariables`](@ref) or [`CodifyPoints`](@ref) discretization scheme. ```@example example_MITsallisFuruichi -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, 200) y = rand(rng, 200) @@ -876,7 +876,7 @@ association(est, x, y) ### [[`EntropyDecomposition`](@ref) + [`LeonenkoProzantoSavani`](@ref)](@id example_MITsallisFuruichi_EntropyDecomposition_LeonenkoProzantoSavani) ```@example example_MITsallisFuruichi -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, 200) y = rand(rng, 200) @@ -889,7 +889,7 @@ association(est_diff, x, y) ### [[`EntropyDecomposition`](@ref) + [`Dispersion`](@ref)](@id example_MITsallisFuruichi_EntropyDecomposition_Dispersion) ```@example example_MITsallisFuruichi -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, 200) y = rand(rng, 200) @@ -905,7 +905,7 @@ association(est_disc, x, y) ### [[`JointProbabilities`](@ref) + [`UniqueElements`](@ref)](@id example_MITsallisMartin_JointProbabilities_UniqueElements) ```@example example_MITsallisMartin -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, 200) y = rand(rng, 200) @@ -922,7 +922,7 @@ that can estimate differential [`Tsallis`](@ref) entropy. ```@example example_MITsallisMartin -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, 500) y = rand(rng, 500) @@ -935,7 +935,7 @@ association(est_diff, x, y) ```@example -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, 200) y = rand(rng, 200) @@ -950,7 +950,7 @@ association(est_disc, x, y) ### [[`CMIShannon`](@ref) with [`GaussianCMI`](@ref)](@id example_CMIShannon_GaussianCMI) ```@example mi_demonstration -using CausalityTools +using Associations using Distributions using Statistics @@ -965,7 +965,7 @@ association(GaussianCMI(), x, z, y) # defaults to `CMIShannon()` ### [[`CMIShannon`](@ref) with [`FPVP`](@ref)](@id example_CMIShannon_FPVP) ```@example mi_demonstration -using CausalityTools +using Associations using Distributions using Statistics @@ -985,7 +985,7 @@ association(FPVP(k = 5), x, z, y) # defaults to `CMIShannon()` ### [`CMIShannon`](@ref) with [`MesnerShalizi`](@ref) ```@example mi_demonstration -using CausalityTools +using Associations using Distributions using Statistics using Random; rng = Xoshiro(1234) @@ -1006,7 +1006,7 @@ association(MesnerShalizi(; k = 10), x, z, y) # defaults to `CMIShannon()` ### [`CMIShannon`](@ref) with [`Rahimzamani`](@ref) ```@example mi_demonstration -using CausalityTools +using Associations using Distributions using Statistics using Random; rng = Xoshiro(1234) @@ -1030,7 +1030,7 @@ Shannon-type conditional mutual information can be decomposed as a sum of mutual information terms, which we can each estimate with any dedicated [`MutualInformationEstimator`](@ref) estimator. ```julia -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x = rand(rng, 300) y = rand(rng, 300) .+ x @@ -1046,7 +1046,7 @@ association(est, x, z, y) # should be near 0 (and can be negative) ### [[`PoczosSchneiderCMI`](@ref)](@id CMIRenyiPoczos_PoczosSchneiderCMI) ```@example example_cmirenyipoczos -using CausalityTools +using Associations using Distributions using Statistics using Random; rng = Xoshiro(1234) @@ -1075,7 +1075,7 @@ taking the difference of mutual information terms. ### [[`MIDecomposition`](@ref) + [`KraskovStögbauerGrassberger1`](@ref)](@id example_CMIShannon_MIDecomposition_KSG1) ```@example mi_demonstration -using CausalityTools +using Associations using Distributions using Statistics @@ -1101,7 +1101,7 @@ usethe [`EntropyDecomposition`](@ref) estimator. No bias correction is applied f [`EntropyDecomposition`](@ref) either. ```@example -using CausalityTools +using Associations using Distributions using Random; rng = Xoshiro(1234) n = 500 @@ -1121,7 +1121,7 @@ discretization (an [`OutcomeSpace`](@ref)). ### [[`EntropyDecomposition`](@ref) + [`ValueBinning`](@ref)](@id example_CMIShannon_EntropyDecomposition_ValueBinning) ```@example -using CausalityTools +using Associations using Distributions using Random; rng = Xoshiro(1234) n = 500 @@ -1140,7 +1140,7 @@ association(est, x, y, z) ### [[`JointProbabilities`](@ref) + [`BubbleSortSwaps`](@ref)](@id example_CMIRenyiJizba_JointProbabilities_BubbleSortSwaps) ```@example example_CMIRenyiJizba -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, 100) y = x .+ rand(rng, 100) @@ -1154,7 +1154,7 @@ association(est, x, z, y) ### [[`EntropyDecomposition`](@ref) + [`LeonenkoProzantoSavani`](@ref)](@id example_CMIRenyiJizba_EntropyDecomposition_LeonenkoProzantoSavani) ```@example example_CMIRenyiJizba -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x, y, z = rand(rng, 1000), rand(rng, 1000), rand(rng, 1000) def = CMIRenyiJizba(q = 1.5) @@ -1168,7 +1168,7 @@ association(est, x, y, z) ### [[`EntropyDecomposition`](@ref) + [`OrdinalPatterns`](@ref)](@id example_CMIRenyiJizba_EntropyDecomposition_OrdinalPatterns) ```@example example_CMIRenyiJizba -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x, y, z = rand(rng, 1000), rand(rng, 1000), rand(rng, 1000) def = CMIRenyiJizba(q = 1.5) @@ -1187,7 +1187,7 @@ there is time-delayed forcing between variables. ```@example transfer_entropy_examples -using CausalityTools +using Associations using DynamicalSystemsBase using StableRNGs rng = StableRNG(123) @@ -1248,7 +1248,7 @@ information transfer. ### [[`CMIDecomposition`](@ref)](@id example_TEShannon_CMIDecomposition) ```@example -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x = rand(rng, 1000) y = rand(rng, 1000) .+ x @@ -1270,7 +1270,7 @@ Thus, we expect that the association for the direction `x → y` is larger than on the intermediate value `y`. ```@example transfer_entropy_examples -using CausalityTools +using Associations using DynamicalSystemsBase using Random; rng = Xoshiro(1234) sys = system(Logistic4Chain(; rng)) @@ -1294,7 +1294,7 @@ We will test terms (without guaranteed cancellation of biases for the total sum). ```@example -using CausalityTools +using Associations using CairoMakie using Statistics using Distributions: Normal @@ -1368,7 +1368,7 @@ discretizing per column of the input data using the [`CodifyVariables`](@ref) di scheme with the [`ValueBinning`](@ref) outcome space. ```@example example_te_schreiber -using CausalityTools +using Associations using DynamicalSystemsBase using CairoMakie using Statistics @@ -1472,7 +1472,7 @@ We can perform the same type of analysis as above using [`TERenyiJizba`](@ref) instead of [`TEShannon`](@ref). ```@example transfer_entropy_examples -using CausalityTools +using Associations using DynamicalSystemsBase using StableRNGs; rng = StableRNG(123) @@ -1496,7 +1496,7 @@ size `l`, and cross mapping is performed using the embedding vectors correspondi to those time indices. ```@example example_ConvergentCrossMapping -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x, y = randn(rng, 200), randn(rng, 200) @@ -1511,7 +1511,7 @@ To generate a distribution of cross-map estimates for each `l ∈ libsizes`, jus crossmap repeatedly, e.g. ```@example example_ConvergentCrossMapping -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) using Statistics @@ -1539,7 +1539,7 @@ size `l`, and cross mapping is performed using the embedding vectors correspondi to those time indices. ```@example example_ConvergentCrossMapping -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x, y = randn(rng, 200), randn(rng, 200) @@ -1554,7 +1554,7 @@ As above, to generate a distribution of cross-map estimates for each `l ∈ libs crossmap repeatedly, e.g. ```@example example_ConvergentCrossMapping -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) using Statistics @@ -1582,7 +1582,7 @@ instead of the convergent cross map algorithm. ```@example example_PairwiseAsymmetricInference -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x, y = randn(rng, 300), randn(rng, 300) @@ -1597,7 +1597,7 @@ To generate a distribution of cross-map estimates for each `l ∈ libsizes`, jus crossmap repeatedly, e.g. ```@example example_PairwiseAsymmetricInference -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) using Statistics @@ -1617,7 +1617,7 @@ f ### [[`RandomSegment`](@ref) estimator](@id example_PairwiseAsymmetricInference_RandomSegment) ```@example example_PairwiseAsymmetricInference -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x, y = randn(rng, 200), randn(rng, 200) @@ -1632,7 +1632,7 @@ As above, to generate a distribution of cross-map estimates for each `l ∈ libs crossmap repeatedly, e.g. ```@example -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) using Statistics @@ -1661,7 +1661,7 @@ from `X` to `Z`. We expect the association between `X` and `Z` to disappear when conditioning on `Y` (since we're then "removing the effect" of `Y`). ```@example example_mcr -using CausalityTools +using Associations using Random; rng = Xoshiro(1234); x = rand(rng, 300); y = rand(rng, 300) .* sin.(x); z = rand(rng, 300) .* y; est = MCR(r = 0.5) @@ -1674,7 +1674,7 @@ Two variables that are uncoupled are symmetrically coupled (i.e. no coupling). W therefore expect the difference in conditional recurrence to be around zero. ```@example -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, 300) y = rand(rng, 300) @@ -1692,7 +1692,7 @@ from `X` to `Z`. We expect the association between `X` and `Z` to disappear when conditioning on `Y` (since we're then "removing the effect" of `Y`). ```@example example_mcr -using CausalityTools +using Associations using Random; rng = Xoshiro(1234); x = rand(rng, 300); y = rand(rng, 300) .* sin.(x); z = rand(rng, 300) .* y; est = RMCD(r = 0.5) diff --git a/docs/src/examples/examples_independence.md b/docs/src/examples/examples_independence.md index 02b8957b3..7b6512076 100644 --- a/docs/src/examples/examples_independence.md +++ b/docs/src/examples/examples_independence.md @@ -4,7 +4,7 @@ ## [[`CorrTest`](@ref)](@id example_CorrTest) ```@example corrtest_example -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) # Some normally distributed data @@ -48,7 +48,7 @@ to see if we can confirm from observed time series that these variables are bidirectionally coupled. We'll use a significance level of `1 - α = 0.99`, i.e. `α = 0.01`. ```@example examples_independence_JointDistanceDistributionTest -using CausalityTools +using Associations using DynamicalSystemsBase using Random; rng = Xoshiro(1234) Base.@kwdef struct Logistic2Bidir{V, C1, C2, R1, R2, Σx, Σy, R} @@ -80,7 +80,7 @@ end We start by generating some time series and configuring the test. ```@example examples_independence_JointDistanceDistributionTest -using CausalityTools +using Associations sys = system(Logistic2Bidir(c_xy = 0.5, c_yx = 0.4)) x, y = columns(first(trajectory(sys, 2000, Ttr = 10000))) measure = JointDistanceDistribution(D = 5, B = 5) @@ -121,7 +121,7 @@ enough evidence in the data to suggest directional coupling. ### [Distance correlation](@id example_SurrogateAssociationTest_DistanceCorrelation) ```@example -using CausalityTools +using Associations x = randn(1000) y = randn(1000) .+ 0.5x independence(SurrogateAssociationTest(DistanceCorrelation()), x, y) @@ -130,7 +130,7 @@ independence(SurrogateAssociationTest(DistanceCorrelation()), x, y) ### [Partial correlation](@id example_SurrogateAssociationTest_PartialCorrelation) ```@example -using CausalityTools +using Associations x = randn(1000) y = randn(1000) .+ 0.5x z = randn(1000) .+ 0.8y @@ -141,7 +141,7 @@ independence(SurrogateAssociationTest(PartialCorrelation()), x, z, y) ### [[`SMeasure`](@ref)](@id example_SurrogateAssociationTest_SMeasure) ```@example example_SurrogateAssociationTest_SMeasure -using CausalityTools +using Associations x, y = randn(1000), randn(1000) measure = SMeasure(dx = 4, dy = 3) s = association(measure, x, y) @@ -175,7 +175,7 @@ evidence in the data to support directional dependence from `x` to `z`. In this example, we expect the `preference` and the `food` variables to be independent. ```@example example_SurrogateAssociationTest_MIShannon_categorical -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) # Simulate n = 1000 @@ -204,7 +204,7 @@ We should be able to reject `places ⫫ experience`, but not reject relationships using (conditional) mutual information. ```@example indep_cmi -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) n = 1000 @@ -247,7 +247,7 @@ and we can't reject the null hypothesis of independence. ### [[`MCR`](@ref)](@id example_independence_MCR) ```@example -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, 300) @@ -259,7 +259,7 @@ independence(test, x, y) As expected, we can't reject independence. What happens if two variables are coupled? ```@example -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x = rand(rng, 300) z = x .+ rand(rng, 300) @@ -320,7 +320,7 @@ entropy estimator, which naively computes CMI as a sum of entropy terms without bias cancellation. ```@example example_LocalPermutationTest -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) n = 100 X = randn(rng, n) @@ -355,7 +355,7 @@ to be non-significant when conditioning on `Y`, because all information from `X` is transferred through `Y`. ```@example example_LocalPermutationTest -using CausalityTools +using Associations using Random; rng = Random.default_rng() n = 300 sys = system(Logistic4Chain(; xi = rand(rng, 4), rng)) diff --git a/docs/src/examples/examples_infer_graphs.md b/docs/src/examples/examples_infer_graphs.md index aee6dd3ca..7dab27426 100644 --- a/docs/src/examples/examples_infer_graphs.md +++ b/docs/src/examples/examples_infer_graphs.md @@ -72,7 +72,7 @@ Here, we use the [`OCE`](@ref) algorithm to infer a time series graph. We use a for the conditional steps. ```@example graph_examples -using CausalityTools +using Associations using StableRNGs rng = StableRNG(123) @@ -117,7 +117,7 @@ also use a parametric correlation test to infer the skeleton graph for some normally distributed data. ```@example graph_examples -using CausalityTools +using Associations using StableRNGs rng = StableRNG(123) n = 300 @@ -150,7 +150,7 @@ with the Shannon mutual information [`MIShannon`](@ref) measure and the and the [`MesnerShalizi`](@ref). ```@example graph_examples -using CausalityTools +using Associations using StableRNGs rng = StableRNG(123) diff --git a/docs/src/index.md b/docs/src/index.md index 71bf13fbf..32714e77d 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -1,28 +1,15 @@ - -```@meta -CollapsedDocStrings = true -``` - -# CausalityTools.jl - -![CausalityTools.jl static logo](assets/logo-large.png) +# Associations.jl ```@docs -CausalityTools +Associations ``` -## Getting started - -The quickest way to get going with the package is to check out the examples in the left-hand menu. - -!!! info - To make it easier to navigate the extensive documentation, all documentation strings are - collapsed by default. Click the arrow icon in - the top toolbar to expand/collapse the docstrings in a page. - ## Latest news -CausalityTools.jl has been updated to v3! +!!! info "Package rename" + The package has been *renamed* from CausalityTools.jl to Associations.jl. + +Associations.jl has been updated to v4! This update includes a number of breaking changes, several of which are *not* backwards compatible. These are done to ensure compatibility with @@ -35,6 +22,15 @@ Important changes are: - `SurrogateTest` has been renamed to [`SurrogateAssociationTest`](@ref). - See the CHANGELOG.md for a complete list of changes. +## Getting started + +The quickest way to get going with the package is to check out the examples in the left-hand menu. + +!!! info + To make it easier to navigate the extensive documentation, all documentation strings are + collapsed by default. Click the arrow icon in + the top toolbar to expand/collapse the docstrings in a page. + ## Documentation content @@ -46,9 +42,9 @@ Important changes are: [independence testing](@ref examples_independence), and [network inference](@ref examples_network_inference). -## Input data for CausalityTools.jl +## Input data for Associations.jl -Input data for CausalityTools.jl are given as: +Input data for Associations.jl are given as: - Univariate *timeseries*, which are given as standard Julia `Vector`s. - Multivariate timeseries, *StateSpaceSets*, or *state space sets*, which are given as @@ -65,7 +61,7 @@ StateSpaceSets.StateSpaceSet ## Maintainers and contributors -The CausalityTools.jl software is maintained by +The Associations.jl software is maintained by [Kristian Agasøster Haaga](https://github.com/kahaaga), who also curates and writes this documentation. Significant contributions to the API and documentation design has been made by [George Datseris](https://github.com/Datseris), which also co-authors diff --git a/src/CausalityTools.jl b/src/Associations.jl similarity index 77% rename from src/CausalityTools.jl rename to src/Associations.jl index 507a16262..58ecf3a42 100644 --- a/src/CausalityTools.jl +++ b/src/Associations.jl @@ -1,11 +1,11 @@ -module CausalityTools +module Associations # Use the README as the module docs @doc let path = joinpath(dirname(@__DIR__), "README.md") include_dependency(path) read(path, String) - end CausalityTools + end Associations using Reexport @@ -40,13 +40,11 @@ module CausalityTools # Update messages: using Scratch display_update = true - version_number = "3.0.0" + version_number = "4.0.0" update_name = "update_v$(version_number)" update_message = """ - \nUpdate message: CausalityTools v$(version_number)\n - - Bivariate and multivariate information measure definitions and estimation is now based on the API in ComplexityMeasures.jl. - - Example systems have been removed from the package to avoid unnecessary package dependencies and improve compilation time. - - Convenience methods have been removed. Use `association` instead. + \nUpdate message: Associations v$(version_number)\n + - The package has been renamed from CausalityTools.jl to Associations.jl! As part of the renaming, Associations.jl has incremented its major version to v4, which is fully backwards compatible with CausalityTools v3. """ if display_update diff --git a/src/causal_graphs/oce/OCE.jl b/src/causal_graphs/oce/OCE.jl index 9370434a8..ad00084bb 100644 --- a/src/causal_graphs/oce/OCE.jl +++ b/src/causal_graphs/oce/OCE.jl @@ -492,7 +492,7 @@ end ######################################################################################### # Compatibility with Graphs.jl ######################################################################################### -function SimpleDiGraph(v::Vector{<:CausalityTools.OCESelectedParents}) +function SimpleDiGraph(v::Vector{<:Associations.OCESelectedParents}) N = length(v) g = SimpleDiGraph(N) for k = 1:N diff --git a/src/deprecations/predictive_asymmetry.jl b/src/deprecations/predictive_asymmetry.jl index c6c85026f..a5fd23088 100644 --- a/src/deprecations/predictive_asymmetry.jl +++ b/src/deprecations/predictive_asymmetry.jl @@ -67,7 +67,7 @@ # ## Examples # ```julia -# using CausalityTools +# using Associations # # Some example time series # x, y = rand(100), rand(100) # # 𝔸(x → y) over prediction lags 1:5 @@ -138,7 +138,7 @@ # function predictive_asymmetry(estimator::VALID_PA_ESTIMATORS, ηs, x::AbstractVector{<:Real}...; # normalize = false, f::Real = 1.0, # dTf = 1, dT = 1, dS = 1, dC = 1, τT = -1, τS = -1, τC = -1, base = 2) -# @warn """`predictive_asymmetry` will be deprecated in CausalityTools 2.0, \ +# @warn """`predictive_asymmetry` will be deprecated in Associations 2.0, \ # and moved to the "Experimental" section until it appears in a peer-reviewed journal. \ # It will reappear with a new signature in a 2.X release.""" # check_ηs(ηs) diff --git a/src/deprecations/v3/smeasure.jl b/src/deprecations/v3/smeasure.jl index 42c5ff26a..d5b82140e 100644 --- a/src/deprecations/v3/smeasure.jl +++ b/src/deprecations/v3/smeasure.jl @@ -14,7 +14,7 @@ synchronization for `s = 1.0`. ## Example ```julia -using CausalityTools +using Associations x, y = rand(1000), rand(1000) diff --git a/src/methods/information/counts_and_probs/encoding/codify_points.jl b/src/methods/information/counts_and_probs/encoding/codify_points.jl index c50f4fc94..0a53ce8e4 100644 --- a/src/methods/information/counts_and_probs/encoding/codify_points.jl +++ b/src/methods/information/counts_and_probs/encoding/codify_points.jl @@ -42,7 +42,7 @@ then that same encoding is applied to every `x[i]`. ## Examples ```julia -using CausalityTools +using Associations # The same encoding on two input datasets x = StateSpaceSet(rand(100, 3)) diff --git a/src/methods/information/counts_and_probs/encoding/codify_variables.jl b/src/methods/information/counts_and_probs/encoding/codify_variables.jl index e3215c6f9..5eaf4701e 100644 --- a/src/methods/information/counts_and_probs/encoding/codify_variables.jl +++ b/src/methods/information/counts_and_probs/encoding/codify_variables.jl @@ -43,7 +43,7 @@ values within each window to an integer. ## Examples ```julia -using CausalityTools +using Associations x, y = rand(100), rand(100) d = CodifyVariables(OrdinalPatterns(m=2)) cx, cy = codify(d, x, y) @@ -85,7 +85,7 @@ Codify each timeseries `xᵢ ∈ x` according to the given encoding/discretizati ## Examples ```julia -using CausalityTools +using Associations # Sliding window encoding x = [0.1, 0.2, 0.3, 0.2, 0.1, 0.0, 0.5, 0.3, 0.5] diff --git a/src/methods/information/definitions/divergences_and_distances/KLDivergence.jl b/src/methods/information/definitions/divergences_and_distances/KLDivergence.jl index b3d365713..1ad7eb6ac 100644 --- a/src/methods/information/definitions/divergences_and_distances/KLDivergence.jl +++ b/src/methods/information/definitions/divergences_and_distances/KLDivergence.jl @@ -41,7 +41,7 @@ D_{KL}(P_Y(\\Omega) || P_Y(\\Omega)) = !!! note Distances.jl also defines `KLDivergence`. Quality it if you're loading both - packages, i.e. do `association(CausalityTools.KLDivergence(), x, y)`. + packages, i.e. do `association(Associations.KLDivergence(), x, y)`. ## Estimation diff --git a/src/methods/information/definitions/divergences_and_distances/RenyiDivergence.jl b/src/methods/information/definitions/divergences_and_distances/RenyiDivergence.jl index 6b770df76..edaed3cb0 100644 --- a/src/methods/information/definitions/divergences_and_distances/RenyiDivergence.jl +++ b/src/methods/information/definitions/divergences_and_distances/RenyiDivergence.jl @@ -39,7 +39,7 @@ D_{q}(P_Y(\\Omega) || P_Y(\\Omega)) = !!! note Distances.jl also defines `RenyiDivergence`. Quality it if you're loading both - packages, i.e. do `association(CausalityTools.RenyiDivergence(), x, y)`. + packages, i.e. do `association(Associations.RenyiDivergence(), x, y)`. ## Estimation diff --git a/src/methods/information/definitions/transferentropy/embedding.jl b/src/methods/information/definitions/transferentropy/embedding.jl index 44fff70ff..83145cd0c 100644 --- a/src/methods/information/definitions/transferentropy/embedding.jl +++ b/src/methods/information/definitions/transferentropy/embedding.jl @@ -104,7 +104,7 @@ The total embedding is then the set of embedding vectors this to code, we get: ```jldoctest -using CausalityTools +using Associations julia> EmbeddingTE(dT=3, τT=[0, -5, -8], dS=2, τS=[-1, -4], ηTf=1) # output diff --git a/src/methods/information/estimators/conditional_mutual_info_estimators/MesnerShalizi.jl b/src/methods/information/estimators/conditional_mutual_info_estimators/MesnerShalizi.jl index 43a741678..f99766b41 100644 --- a/src/methods/information/estimators/conditional_mutual_info_estimators/MesnerShalizi.jl +++ b/src/methods/information/estimators/conditional_mutual_info_estimators/MesnerShalizi.jl @@ -22,7 +22,7 @@ number of temporal neighbors that are excluded during neighbor searches. ## Examples ```julia -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x = rand(rng, 10000) y = rand(rng, 10000) .+ x diff --git a/src/methods/information/estimators/conditional_mutual_info_estimators/PoczosSchneiderCMI.jl b/src/methods/information/estimators/conditional_mutual_info_estimators/PoczosSchneiderCMI.jl index 3792d83ff..0d1de616a 100644 --- a/src/methods/information/estimators/conditional_mutual_info_estimators/PoczosSchneiderCMI.jl +++ b/src/methods/information/estimators/conditional_mutual_info_estimators/PoczosSchneiderCMI.jl @@ -25,7 +25,7 @@ number of temporal neighbors that are excluded during neighbor searches. ## Examples ```julia -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x = rand(rng, 10000) y = rand(rng, 10000) .+ x diff --git a/src/methods/information/estimators/conditional_mutual_info_estimators/Rahimzamani.jl b/src/methods/information/estimators/conditional_mutual_info_estimators/Rahimzamani.jl index e13b47cdb..a86268aa6 100644 --- a/src/methods/information/estimators/conditional_mutual_info_estimators/Rahimzamani.jl +++ b/src/methods/information/estimators/conditional_mutual_info_estimators/Rahimzamani.jl @@ -27,7 +27,7 @@ number of temporal neighbors that are excluded during neighbor searches. ## Examples ```julia -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x = rand(rng, 10000) y = rand(rng, 10000) .+ x diff --git a/src/methods/information/estimators/mutual_info_estimators/GaoKannanOhViswanath.jl b/src/methods/information/estimators/mutual_info_estimators/GaoKannanOhViswanath.jl index 359677fd3..55ca8b36c 100644 --- a/src/methods/information/estimators/mutual_info_estimators/GaoKannanOhViswanath.jl +++ b/src/methods/information/estimators/mutual_info_estimators/GaoKannanOhViswanath.jl @@ -58,7 +58,7 @@ variables (by quantization) or making it continuous by adding a small Gaussian n ## Examples ```julia -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x = rand(rng, 10000); y = rand(rng, 10000) association(GaoKannanOhViswanath(; k = 10), x, y) # should be near 0 (and can be negative) diff --git a/src/methods/information/estimators/mutual_info_estimators/GaoOhViswanath.jl b/src/methods/information/estimators/mutual_info_estimators/GaoOhViswanath.jl index 071ec7f8e..4ecdfd6e5 100644 --- a/src/methods/information/estimators/mutual_info_estimators/GaoOhViswanath.jl +++ b/src/methods/information/estimators/mutual_info_estimators/GaoOhViswanath.jl @@ -41,7 +41,7 @@ volume of a ``d``-dimensional unit ``\\mathcal{l}_2``-ball. ## Example ```julia -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x = rand(rng, 10000); y = rand(rng, 10000) association(GaoOhViswanath(; k = 10), x, y) # should be near 0 (and can be negative) diff --git a/src/methods/information/estimators/mutual_info_estimators/GaussianMI.jl b/src/methods/information/estimators/mutual_info_estimators/GaussianMI.jl index 6d21ea660..d450187b4 100644 --- a/src/methods/information/estimators/mutual_info_estimators/GaussianMI.jl +++ b/src/methods/information/estimators/mutual_info_estimators/GaussianMI.jl @@ -62,7 +62,7 @@ where ``\\sigma_i`` are the eigenvalues for ``\\Sigma``. ## Example ```julia -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x = rand(rng, 10000); y = rand(rng, 10000) association(GaussianMI(), x, y) # should be near 0 (and can be negative) diff --git a/src/methods/information/estimators/mutual_info_estimators/KSG1.jl b/src/methods/information/estimators/mutual_info_estimators/KSG1.jl index 8809f9022..71adb71b0 100644 --- a/src/methods/information/estimators/mutual_info_estimators/KSG1.jl +++ b/src/methods/information/estimators/mutual_info_estimators/KSG1.jl @@ -44,7 +44,7 @@ short) is the ``I^{(1)}`` `k`-th nearest neighbor estimator from [Kraskov2004](@ ## Example ```julia -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x = rand(rng, 10000); y = rand(rng, 10000) association(KSG1(; k = 10), x, y) # should be near 0 (and can be negative) diff --git a/src/methods/information/estimators/mutual_info_estimators/KSG2.jl b/src/methods/information/estimators/mutual_info_estimators/KSG2.jl index 1362fae12..b05ca6aa8 100644 --- a/src/methods/information/estimators/mutual_info_estimators/KSG2.jl +++ b/src/methods/information/estimators/mutual_info_estimators/KSG2.jl @@ -66,7 +66,7 @@ then estimated as ## Example ```julia -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x = rand(rng, 10000); y = rand(rng, 10000) association(KSG2(; k = 10), x, y) # should be near 0 (and can be negative) diff --git a/src/methods/information/estimators/transfer_entropy_estimators/Lindner.jl b/src/methods/information/estimators/transfer_entropy_estimators/Lindner.jl index b6ece0920..d2d540502 100644 --- a/src/methods/information/estimators/transfer_entropy_estimators/Lindner.jl +++ b/src/methods/information/estimators/transfer_entropy_estimators/Lindner.jl @@ -51,7 +51,7 @@ conditioning too (a simple modification to [Lindner2011](@citet)'s equation 5 an ## Example ```julia -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x = rand(rng, 10000) y = rand(rng, 10000) .+ x diff --git a/src/methods/information/estimators/transfer_entropy_estimators/Zhu1.jl b/src/methods/information/estimators/transfer_entropy_estimators/Zhu1.jl index 71188add2..6107c4bb0 100644 --- a/src/methods/information/estimators/transfer_entropy_estimators/Zhu1.jl +++ b/src/methods/information/estimators/transfer_entropy_estimators/Zhu1.jl @@ -57,7 +57,7 @@ conditioning too (a simple modification to [Lindner2011](@citet)'s equation 5 an ## Example ```julia -using CausalityTools +using Associations using Random; rng = MersenneTwister(1234) x = rand(rng, 10000) y = rand(rng, 10000) .+ x diff --git a/test/causal_graphs/oce.jl b/test/causal_graphs/oce.jl index a3a124abd..1f9f7d406 100644 --- a/test/causal_graphs/oce.jl +++ b/test/causal_graphs/oce.jl @@ -1,5 +1,5 @@ -using CausalityTools -using CausalityTools: OCESelectedParents +using Associations +using Associations: OCESelectedParents using Test using StableRNGs using Graphs.SimpleGraphs: SimpleEdge diff --git a/test/independence/JointDistanceDistributionTest.jl b/test/independence/JointDistanceDistributionTest.jl index 2bdaeda5a..33d49c529 100644 --- a/test/independence/JointDistanceDistributionTest.jl +++ b/test/independence/JointDistanceDistributionTest.jl @@ -4,7 +4,7 @@ x, y = randn(rng, 1000), randn(rng, 1000) m = JointDistanceDistribution(D = 3, B = 5) test = JointDistanceDistributionTest(m) @test test isa JointDistanceDistributionTest -@test independence(test, x, y) isa CausalityTools.JDDTestResult +@test independence(test, x, y) isa Associations.JDDTestResult # Don't reject null at significance level (1 - α) when there is no coupling. α = 0.05 diff --git a/test/independence/LocalPermutationTest/api.jl b/test/independence/LocalPermutationTest/api.jl index f6ac52d37..5430fc1fc 100644 --- a/test/independence/LocalPermutationTest/api.jl +++ b/test/independence/LocalPermutationTest/api.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using StableRNGs rng = StableRNG(123) @@ -41,18 +41,18 @@ independence_test = LocalPermutationTest(FPVP(CMIShannon()), nshuffles = 2) res = independence(independence_test, x, z, y) # Internals -out_str_pval = repr( CausalityTools.pvalue_text_summary(res)) +out_str_pval = repr( Associations.pvalue_text_summary(res)) @test occursin("p-value:", out_str_pval) # Internals -out_str_pval = repr( CausalityTools.quantiles_text(res)) +out_str_pval = repr( Associations.quantiles_text(res)) @test occursin("Ensemble quantiles", out_str_pval) -out_str_conclusion = repr( CausalityTools.null_hypothesis_text(res)) +out_str_conclusion = repr( Associations.null_hypothesis_text(res)) @test occursin("The first two variables are independent, given the 3rd variable", out_str_conclusion) independence_test = SurrogateAssociationTest(KSG1(MIShannon())) res = independence(independence_test, x, y) -out_str_conclusion = repr( CausalityTools.null_hypothesis_text(res)) +out_str_conclusion = repr( Associations.null_hypothesis_text(res)) @test occursin("The variables are independent", out_str_conclusion) diff --git a/test/independence/LocalPermutationTest/conditional_mutual_information.jl b/test/independence/LocalPermutationTest/conditional_mutual_information.jl index 864054d89..4c092fef6 100644 --- a/test/independence/LocalPermutationTest/conditional_mutual_information.jl +++ b/test/independence/LocalPermutationTest/conditional_mutual_information.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using StableRNGs rng = StableRNG(123) diff --git a/test/independence/LocalPermutationTest/distance_correlation.jl b/test/independence/LocalPermutationTest/distance_correlation.jl index 89c28c8bf..101b25297 100644 --- a/test/independence/LocalPermutationTest/distance_correlation.jl +++ b/test/independence/LocalPermutationTest/distance_correlation.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using StableRNGs rng = StableRNG(123) diff --git a/test/independence/LocalPermutationTest/part_mutual_information.jl b/test/independence/LocalPermutationTest/part_mutual_information.jl index 156cc1621..a808677bb 100644 --- a/test/independence/LocalPermutationTest/part_mutual_information.jl +++ b/test/independence/LocalPermutationTest/part_mutual_information.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using StableRNGs rng = StableRNG(123) diff --git a/test/independence/LocalPermutationTest/partial_correlation.jl b/test/independence/LocalPermutationTest/partial_correlation.jl index 8e842d3e9..0946bb824 100644 --- a/test/independence/LocalPermutationTest/partial_correlation.jl +++ b/test/independence/LocalPermutationTest/partial_correlation.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using StableRNGs rng = StableRNG(123) diff --git a/test/independence/LocalPermutationTest/transferentropy.jl b/test/independence/LocalPermutationTest/transferentropy.jl index a1134a828..c624ad514 100644 --- a/test/independence/LocalPermutationTest/transferentropy.jl +++ b/test/independence/LocalPermutationTest/transferentropy.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using StableRNGs rng = StableRNG(123) diff --git a/test/independence/PATest.jl b/test/independence/PATest.jl index 9841720a7..4f4a0220c 100644 --- a/test/independence/PATest.jl +++ b/test/independence/PATest.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using DynamicalSystemsBase using Random diff --git a/test/methods/correlation/distance_correlation.jl b/test/methods/correlation/distance_correlation.jl index 409830538..34214c779 100644 --- a/test/methods/correlation/distance_correlation.jl +++ b/test/methods/correlation/distance_correlation.jl @@ -4,7 +4,7 @@ using Test # ----------------- a = StateSpaceSet(repeat([1], 100)) # TODO: export this method? -@test CausalityTools.distance_variance(a) == 0.0 +@test Associations.distance_variance(a) == 0.0 v = rand(1000, 3); w = 0.5 .* v .+ 1.2; @test association(DistanceCorrelation(), v, w) ≈ 1.0 @@ -20,17 +20,17 @@ dcov = association(DistanceCorrelation(), x, y) # ---------------------------- # Test internals by checking that we get the same answer as in the R `energy` package. M = reshape([0.0, 0.2, 0.3, 0.2, 0.0, 0.6, 0.3, 0.6, 0.3], 3, 3) -@test CausalityTools.ucenter(M) ≈ +@test Associations.ucenter(M) ≈ [0 0.15 -0.15; 0.15 0.0 -0.15; -0.15 -0.15 0.0] @test round(association(DistanceCorrelation(), x, z, y), digits = 5) ≈ round(0.1556139, digits = 5) -@test round(CausalityTools.distance_covariance(x, z, y), digits = 5) ≈ round(0.02379782, digits = 5) +@test round(Associations.distance_covariance(x, z, y), digits = 5) ≈ round(0.02379782, digits = 5) # Deprecations @test_logs (:warn, "Convenience function `distance_correlation` is deprecated. Use `association(DistanceCorrelation(), x, y)` instead.") distance_correlation(x, y) @test_logs (:warn, "Convenience function `distance_correlation` is deprecated. Use `association(DistanceCorrelation(), x, y, z)` instead.") distance_correlation(x, y, z) -@test CausalityTools.min_inputs_vars(DistanceCorrelation()) == 2 -@test CausalityTools.max_inputs_vars(DistanceCorrelation()) == 3 \ No newline at end of file +@test Associations.min_inputs_vars(DistanceCorrelation()) == 2 +@test Associations.max_inputs_vars(DistanceCorrelation()) == 3 \ No newline at end of file diff --git a/test/methods/correlation/partial_correlation.jl b/test/methods/correlation/partial_correlation.jl index 93f84c97d..e6ac1e3e8 100644 --- a/test/methods/correlation/partial_correlation.jl +++ b/test/methods/correlation/partial_correlation.jl @@ -8,5 +8,5 @@ z = rand(100, 2) @test_logs (:warn, "Convenience function `partial_correlation` is deprecated. Use `association(PartialCorrelation(), x, y, z)` instead.") partial_correlation(x, y, z) -@test CausalityTools.min_inputs_vars(PartialCorrelation()) == 3 -@test CausalityTools.max_inputs_vars(PartialCorrelation()) == Inf \ No newline at end of file +@test Associations.min_inputs_vars(PartialCorrelation()) == 3 +@test Associations.max_inputs_vars(PartialCorrelation()) == Inf \ No newline at end of file diff --git a/test/methods/cross_mappings/ccm_like.jl b/test/methods/cross_mappings/ccm_like.jl index ee984e578..ec9f4fe0a 100644 --- a/test/methods/cross_mappings/ccm_like.jl +++ b/test/methods/cross_mappings/ccm_like.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using StateSpaceSets using Random rng = Xoshiro(1234) @@ -38,24 +38,24 @@ rng = Xoshiro(1234) @testset "Embed using CCM" begin x, y = rand(rng, 100), rand(rng, 100) # Embedding - d, colidx_target, colidxs_source = CausalityTools.embed(ConvergentCrossMapping(), x, y) + d, colidx_target, colidxs_source = Associations.embed(ConvergentCrossMapping(), x, y) @test d isa AbstractStateSpaceSet @test colidx_target isa Int @test colidxs_source isa AbstractVector{Int} # Segment length - @test CausalityTools.max_segmentlength(def, rand(10)) == 10 - 2 + 1 + @test Associations.max_segmentlength(def, rand(10)) == 10 - 2 + 1 def = ConvergentCrossMapping(d = 2) # Num of neighbors def = ConvergentCrossMapping(d = 2) - @test CausalityTools.n_neighbors_simplex(def) == 3 + @test Associations.n_neighbors_simplex(def) == 3 # If using forward embedding, warn. msg = """τ > 0. You're using future values of source to predict the target. Turn \ off this warning by setting `embed_warn = false` in the \ `PairwiseAsymmetricInference` constructor.""" - @test_warn msg CausalityTools.embed(ConvergentCrossMapping(τ = 1), x, y) + @test_warn msg Associations.embed(ConvergentCrossMapping(τ = 1), x, y) end end @@ -81,24 +81,24 @@ end @testset "Embed using CCM" begin x, y = rand(rng, 100), rand(rng, 100) # Embedding - d, colidx_target, colidxs_source = CausalityTools.embed(def, x, y) + d, colidx_target, colidxs_source = Associations.embed(def, x, y) @test d isa AbstractStateSpaceSet @test colidx_target isa Int @test colidxs_source isa AbstractVector{Int} # Segment length - @test CausalityTools.max_segmentlength(def, rand(10)) == 10 - 2 + 1 + @test Associations.max_segmentlength(def, rand(10)) == 10 - 2 + 1 def = ConvergentCrossMapping(d = 2) # Num of neighbors def = ConvergentCrossMapping(d = 2) - @test CausalityTools.n_neighbors_simplex(def) == 3 + @test Associations.n_neighbors_simplex(def) == 3 # If using forward embedding, warn. msg = """τ > 0. You're using future values of source to predict the target. Turn \ off this warning by setting `embed_warn = false` in the \ `PairwiseAsymmetricInference` constructor.""" - @test_warn msg CausalityTools.embed(ConvergentCrossMapping(τ = 1), x, y) + @test_warn msg Associations.embed(ConvergentCrossMapping(τ = 1), x, y) end end diff --git a/test/methods/information/conditional_entropies/ce_shannon.jl b/test/methods/information/conditional_entropies/ce_shannon.jl index 3f9790140..371feebe6 100644 --- a/test/methods/information/conditional_entropies/ce_shannon.jl +++ b/test/methods/information/conditional_entropies/ce_shannon.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using Random rng = Xoshiro(1234) @@ -7,8 +7,8 @@ rng = Xoshiro(1234) # Internals # --------------- def = ConditionalEntropyShannon() -@test CausalityTools.min_inputs_vars(def) == 2 -@test CausalityTools.max_inputs_vars(def) == 2 +@test Associations.min_inputs_vars(def) == 2 +@test Associations.max_inputs_vars(def) == 2 p_nonzeros = Probabilities([0.5 0.5; 0.1 0.1 ]) p_zeros = Probabilities([0.5 0.0; 0.1 0.1]) diff --git a/test/methods/information/conditional_entropies/ce_tsallis_abe.jl b/test/methods/information/conditional_entropies/ce_tsallis_abe.jl index 7cc7e929e..7a59e5e9c 100644 --- a/test/methods/information/conditional_entropies/ce_tsallis_abe.jl +++ b/test/methods/information/conditional_entropies/ce_tsallis_abe.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using Random @@ -7,8 +7,8 @@ using Random # Internals # --------------- def = ConditionalEntropyTsallisAbe() -@test CausalityTools.min_inputs_vars(def) == 2 -@test CausalityTools.max_inputs_vars(def) == 2 +@test Associations.min_inputs_vars(def) == 2 +@test Associations.max_inputs_vars(def) == 2 # --------------------------------------------------------------------------------------- diff --git a/test/methods/information/conditional_entropies/ce_tsallis_furuichi.jl b/test/methods/information/conditional_entropies/ce_tsallis_furuichi.jl index 55f3b1766..94220598b 100644 --- a/test/methods/information/conditional_entropies/ce_tsallis_furuichi.jl +++ b/test/methods/information/conditional_entropies/ce_tsallis_furuichi.jl @@ -1,12 +1,12 @@ using Test -using CausalityTools +using Associations # --------------- # Internals # --------------- def = ConditionalEntropyTsallisFuruichi() -@test CausalityTools.min_inputs_vars(def) == 2 -@test CausalityTools.max_inputs_vars(def) == 2 +@test Associations.min_inputs_vars(def) == 2 +@test Associations.max_inputs_vars(def) == 2 # --------------------------------------------------------------------------------------- diff --git a/test/methods/information/conditional_mutual_informations/cmi_renyi_jizba.jl b/test/methods/information/conditional_mutual_informations/cmi_renyi_jizba.jl index 5355fcdc6..fb64ad9be 100644 --- a/test/methods/information/conditional_mutual_informations/cmi_renyi_jizba.jl +++ b/test/methods/information/conditional_mutual_informations/cmi_renyi_jizba.jl @@ -1,4 +1,4 @@ -using CausalityTools +using Associations using Test # --------------- diff --git a/test/methods/information/conditional_mutual_informations/cmi_renyi_poczos.jl b/test/methods/information/conditional_mutual_informations/cmi_renyi_poczos.jl index 833d945c8..e7398e0cc 100644 --- a/test/methods/information/conditional_mutual_informations/cmi_renyi_poczos.jl +++ b/test/methods/information/conditional_mutual_informations/cmi_renyi_poczos.jl @@ -1,6 +1,6 @@ using Test -using CausalityTools +using Associations using Random rng = MersenneTwister(1234) @@ -13,8 +13,8 @@ z = randn(rng, 50) # Internals # --------------- def = CMIRenyiPoczos() -@test CausalityTools.min_inputs_vars(def) == 3 -@test CausalityTools.max_inputs_vars(def) == 3 +@test Associations.min_inputs_vars(def) == 3 +@test Associations.max_inputs_vars(def) == 3 # --------------------------------------------------------------------------------------- # Test all possible ways of estimating `CMIRenyiPoczos`. diff --git a/test/methods/information/conditional_mutual_informations/cmi_renyi_sarbu.jl b/test/methods/information/conditional_mutual_informations/cmi_renyi_sarbu.jl index 55c1cf940..217f0ba22 100644 --- a/test/methods/information/conditional_mutual_informations/cmi_renyi_sarbu.jl +++ b/test/methods/information/conditional_mutual_informations/cmi_renyi_sarbu.jl @@ -1,16 +1,16 @@ using Test -using CausalityTools +using Associations def = CMIRenyiSarbu() -@test CausalityTools.min_inputs_vars(def) == 3 -@test CausalityTools.max_inputs_vars(def) == 3 +@test Associations.min_inputs_vars(def) == 3 +@test Associations.max_inputs_vars(def) == 3 # --------------- # Internals # --------------- def = CMIRenyiSarbu() -@test CausalityTools.min_inputs_vars(def) == 3 -@test CausalityTools.max_inputs_vars(def) == 3 +@test Associations.min_inputs_vars(def) == 3 +@test Associations.max_inputs_vars(def) == 3 # Double-sum estimation. x = rand(["a", "b", "c"], 50) diff --git a/test/methods/information/conditional_mutual_informations/cmi_shannon.jl b/test/methods/information/conditional_mutual_informations/cmi_shannon.jl index 531b151cf..2a44b51e5 100644 --- a/test/methods/information/conditional_mutual_informations/cmi_shannon.jl +++ b/test/methods/information/conditional_mutual_informations/cmi_shannon.jl @@ -1,6 +1,6 @@ using Test -using CausalityTools +using Associations using Random rng = MersenneTwister(1234) @@ -8,8 +8,8 @@ rng = MersenneTwister(1234) # Internals # --------------- def = CMIShannon() -@test CausalityTools.min_inputs_vars(def) == 3 -@test CausalityTools.max_inputs_vars(def) == 3 +@test Associations.min_inputs_vars(def) == 3 +@test Associations.max_inputs_vars(def) == 3 # --------------- # Input checks diff --git a/test/methods/information/conditional_mutual_informations/cmi_tsallis_papetrou.jl b/test/methods/information/conditional_mutual_informations/cmi_tsallis_papetrou.jl index 32d96e3d1..612893a85 100644 --- a/test/methods/information/conditional_mutual_informations/cmi_tsallis_papetrou.jl +++ b/test/methods/information/conditional_mutual_informations/cmi_tsallis_papetrou.jl @@ -1,11 +1,11 @@ using Test -using CausalityTools +using Associations # --------------- # Internals # --------------- def = CMITsallisPapapetrou() -@test CausalityTools.min_inputs_vars(def) == 3 -@test CausalityTools.max_inputs_vars(def) == 3 +@test Associations.min_inputs_vars(def) == 3 +@test Associations.max_inputs_vars(def) == 3 # --------------------------------------------------------------------------------------- # Test all possible ways of estimating `CMIRenyiJizba`. diff --git a/test/methods/information/core/counts.jl b/test/methods/information/core/counts.jl index ade38e27d..f465b5d7b 100644 --- a/test/methods/information/core/counts.jl +++ b/test/methods/information/core/counts.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using Random rng = Xoshiro(1234) @@ -64,7 +64,7 @@ d_row = CodifyPoints(OrdinalPatternEncoding{2}()); # Multiple outcome spaces with the same cardinality with `CodifyVariables` using Test -using CausalityTools +using Associations using Random; rng = Xoshiro(1234) x, y = rand(rng, 100), rand(rng, 100) # We must use outcome spaces with the same number of total outcomes. diff --git a/test/methods/information/core/encoding.jl b/test/methods/information/core/encoding.jl index 14d106b1d..4fc152d84 100644 --- a/test/methods/information/core/encoding.jl +++ b/test/methods/information/core/encoding.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using Random rng = Xoshiro(1234) diff --git a/test/methods/information/core/probabilities.jl b/test/methods/information/core/probabilities.jl index 1e6d04377..c154a17fd 100644 --- a/test/methods/information/core/probabilities.jl +++ b/test/methods/information/core/probabilities.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using Random rng = Xoshiro(1234) diff --git a/test/methods/information/distances_and_divergences/hellinger_distance.jl b/test/methods/information/distances_and_divergences/hellinger_distance.jl index 7b41f54be..fc3c7a00e 100644 --- a/test/methods/information/distances_and_divergences/hellinger_distance.jl +++ b/test/methods/information/distances_and_divergences/hellinger_distance.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations # There should be zero information gain from `x` over `y` for independent random variables. using Random diff --git a/test/methods/information/distances_and_divergences/kl_divergence.jl b/test/methods/information/distances_and_divergences/kl_divergence.jl index 34578746f..000fe28fe 100644 --- a/test/methods/information/distances_and_divergences/kl_divergence.jl +++ b/test/methods/information/distances_and_divergences/kl_divergence.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations # There should be zero information gain from `x` over `y` for independent random variables. using Random diff --git a/test/methods/information/distances_and_divergences/renyi_divergence.jl b/test/methods/information/distances_and_divergences/renyi_divergence.jl index ffe6ff84b..6c2f127f0 100644 --- a/test/methods/information/distances_and_divergences/renyi_divergence.jl +++ b/test/methods/information/distances_and_divergences/renyi_divergence.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations # There should be zero information gain from `x` over `y` for independent random variables. using Random diff --git a/test/methods/information/estimators/joint.jl b/test/methods/information/estimators/joint.jl index 90c5ca1d0..744f83e2f 100644 --- a/test/methods/information/estimators/joint.jl +++ b/test/methods/information/estimators/joint.jl @@ -1,4 +1,4 @@ -using CausalityTools +using Associations using Test using Random rng = Xoshiro(1234) diff --git a/test/methods/information/internal_api.jl b/test/methods/information/internal_api.jl index f46792d59..b7b025459 100644 --- a/test/methods/information/internal_api.jl +++ b/test/methods/information/internal_api.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations # ---------------------------------------------------------------- # This file tests internal functions. @@ -11,9 +11,9 @@ est_renyi = PlugIn(Renyi(; q = 0.5, base = 2)) est_tsallis = PlugIn(Tsallis(; q = 0.5, base = 2)) est_shannon = PlugIn(Shannon(; base = 2)) -new_est_renyi = CausalityTools.estimator_with_overridden_parameters(def_renyi, est_renyi) -new_est_tsallis = CausalityTools.estimator_with_overridden_parameters(def_tsallis, est_tsallis) -new_est_shannon = CausalityTools.estimator_with_overridden_parameters(def_shannon, est_shannon) +new_est_renyi = Associations.estimator_with_overridden_parameters(def_renyi, est_renyi) +new_est_tsallis = Associations.estimator_with_overridden_parameters(def_tsallis, est_tsallis) +new_est_shannon = Associations.estimator_with_overridden_parameters(def_shannon, est_shannon) @test new_est_renyi == PlugIn(Renyi(; q = 5, base = 5)) @test new_est_tsallis == PlugIn(Tsallis(; q = 5, base = 5)) @test new_est_shannon == PlugIn(Shannon(; base = 5)) @@ -21,7 +21,7 @@ new_est_shannon = CausalityTools.estimator_with_overridden_parameters(def_shanno p1 = Probabilities([0.1, 0.2, 0.3]) p2 = Probabilities([0.1, 0.2, 0.3, 0.4]) -@test_throws DimensionMismatch CausalityTools.size_match(KLDivergence(), p1, p2) +@test_throws DimensionMismatch Associations.size_match(KLDivergence(), p1, p2) struct BogusMeasure2{M} <: MultivariateInformationMeasure def::M diff --git a/test/methods/information/joint_entropies/joint_entropy_renyi.jl b/test/methods/information/joint_entropies/joint_entropy_renyi.jl index a755f6630..46167e8d4 100644 --- a/test/methods/information/joint_entropies/joint_entropy_renyi.jl +++ b/test/methods/information/joint_entropies/joint_entropy_renyi.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations x = rand(["a", "b", "c"], 200) y = rand(["hello", "yoyo", "heyhey"], 200) diff --git a/test/methods/information/joint_entropies/joint_entropy_shannon.jl b/test/methods/information/joint_entropies/joint_entropy_shannon.jl index db7bc14d8..179182d18 100644 --- a/test/methods/information/joint_entropies/joint_entropy_shannon.jl +++ b/test/methods/information/joint_entropies/joint_entropy_shannon.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations x = rand(["a", "b", "c"], 200) y = rand(["hello", "yoyo", "heyhey"], 200) diff --git a/test/methods/information/joint_entropies/joint_entropy_tsallis.jl b/test/methods/information/joint_entropies/joint_entropy_tsallis.jl index b48f4965e..532f8a272 100644 --- a/test/methods/information/joint_entropies/joint_entropy_tsallis.jl +++ b/test/methods/information/joint_entropies/joint_entropy_tsallis.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations x = rand(["a", "b", "c"], 200) y = rand(["hello", "yoyo", "heyhey"], 200) diff --git a/test/methods/information/mutual_informations/api.jl b/test/methods/information/mutual_informations/api.jl index 8d12e6362..5af0ffe5d 100644 --- a/test/methods/information/mutual_informations/api.jl +++ b/test/methods/information/mutual_informations/api.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using Random rng = MersenneTwister(1234) diff --git a/test/methods/information/mutual_informations/mi_renyi_jizba.jl b/test/methods/information/mutual_informations/mi_renyi_jizba.jl index c082d6f92..9ecb0aff3 100644 --- a/test/methods/information/mutual_informations/mi_renyi_jizba.jl +++ b/test/methods/information/mutual_informations/mi_renyi_jizba.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using Random rng = MersenneTwister(1234) diff --git a/test/methods/information/mutual_informations/mi_renyi_sarbu.jl b/test/methods/information/mutual_informations/mi_renyi_sarbu.jl index 545e8ddf1..617019e89 100644 --- a/test/methods/information/mutual_informations/mi_renyi_sarbu.jl +++ b/test/methods/information/mutual_informations/mi_renyi_sarbu.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations # Double-sum estimation. x = rand(["a", "b", "c"], 200) diff --git a/test/methods/information/mutual_informations/mi_shannon.jl b/test/methods/information/mutual_informations/mi_shannon.jl index 75d4e5396..fbd1686b7 100644 --- a/test/methods/information/mutual_informations/mi_shannon.jl +++ b/test/methods/information/mutual_informations/mi_shannon.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using Random rng = MersenneTwister(1234) def = MIShannon() diff --git a/test/methods/information/mutual_informations/mi_tsallis_furuichi.jl b/test/methods/information/mutual_informations/mi_tsallis_furuichi.jl index 80b6309ae..dfe2e1999 100644 --- a/test/methods/information/mutual_informations/mi_tsallis_furuichi.jl +++ b/test/methods/information/mutual_informations/mi_tsallis_furuichi.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using Random rng = Xoshiro(1234) diff --git a/test/methods/information/mutual_informations/mi_tsallis_martin.jl b/test/methods/information/mutual_informations/mi_tsallis_martin.jl index 5f0c5f238..c61047b1b 100644 --- a/test/methods/information/mutual_informations/mi_tsallis_martin.jl +++ b/test/methods/information/mutual_informations/mi_tsallis_martin.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using Random rng = Xoshiro(1234) diff --git a/test/methods/information/transfer_entropies/te_renyi_jizba.jl b/test/methods/information/transfer_entropies/te_renyi_jizba.jl index b098f71eb..58714e0ea 100644 --- a/test/methods/information/transfer_entropies/te_renyi_jizba.jl +++ b/test/methods/information/transfer_entropies/te_renyi_jizba.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using Random rng = MersenneTwister(1234) diff --git a/test/methods/information/transfer_entropies/te_shannon.jl b/test/methods/information/transfer_entropies/te_shannon.jl index dc2358d9d..5a39543fb 100644 --- a/test/methods/information/transfer_entropies/te_shannon.jl +++ b/test/methods/information/transfer_entropies/te_shannon.jl @@ -1,5 +1,5 @@ using Test -using CausalityTools +using Associations using DynamicalSystemsBase using Random rng = Xoshiro(1234) @@ -67,7 +67,7 @@ est = Hilbert(est_te) @test association(Hilbert(est, source = Amplitude(), target = Amplitude(), cond = Amplitude() ), x, y, z) >= 0.0 @test association(Hilbert(est, source = Phase(), target = Phase(), cond = Amplitude() ), x, y, z) >= 0.0 -struct SillySignalProperty <: CausalityTools.InstantaneousSignalProperty +struct SillySignalProperty <: Associations.InstantaneousSignalProperty end @test_throws ArgumentError association(Hilbert(est, source = SillySignalProperty()), x, y) @test_throws ArgumentError association(Hilbert(est, target = SillySignalProperty()), x, y) diff --git a/test/methods/information/transfer_entropies/utils.jl b/test/methods/information/transfer_entropies/utils.jl index fd1d26412..ac1cadcf0 100644 --- a/test/methods/information/transfer_entropies/utils.jl +++ b/test/methods/information/transfer_entropies/utils.jl @@ -17,12 +17,12 @@ x, y, z = rand(100), rand(100), rand(100) # Internals that we may not necessarily hit using random input data. # ---------------------------------------------------------------- emb = EmbeddingTE(OptimiseTraditional(), x, y, z) -pts, vars, τs, js = CausalityTools.te_embed(emb, x, y) +pts, vars, τs, js = Associations.te_embed(emb, x, y) @test occursin("Tf = ", repr(vars)) # TEVars -vars1 = CausalityTools.TEVars([1], [2], [3]) -vars2 = CausalityTools.TEVars([1], [2], [3], Int[]) +vars1 = Associations.TEVars([1], [2], [3]) +vars2 = Associations.TEVars([1], [2], [3], Int[]) @test vars1.C == vars2.C # rc @@ -30,7 +30,7 @@ vars2 = CausalityTools.TEVars([1], [2], [3], Int[]) x = rand(100) X = StateSpaceSet(rand(100)) -rc = CausalityTools.rc +rc = Associations.rc # If multiple lags are given, and the dimension is an integer, then the number of # lags must match the dimension. ds = 4 diff --git a/test/runtests.jl b/test/runtests.jl index 96f50ec71..aaafd1eeb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,9 +1,9 @@ using Test -using CausalityTools +using Associations defaultname(file) = uppercasefirst(replace(splitext(basename(file))[1], '_' => ' ')) testfile(file, testname=defaultname(file)) = @testset "$testname" begin; include(file); end -@testset "CausalityTools.jl" begin +@testset "Associations.jl" begin include("test_systems.jl") testfile("deprecations.jl") testfile("methods/methods.jl")