Skip to content

Commit

Permalink
Chatterjee coefficient (#383)
Browse files Browse the repository at this point in the history
* Chatterjee coefficient.

* Finalize Chatterjee correlation

* Fix examples

* Fix badges

* Add missing references in tables

* Add reference

* Remove unnecessary folder

* Reproducible tests

* Use .= syntax
  • Loading branch information
kahaaga authored Aug 1, 2024
1 parent d5268cf commit 8d1c2e4
Show file tree
Hide file tree
Showing 16 changed files with 440 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "Associations"
uuid = "614afb3a-e278-4863-8805-9959372b9ec2"
authors = ["Kristian Agasøster Haaga <[email protected]>", "Tor Einar Møller <[email protected]>", "George Datseris <[email protected]>"]
repo = "https://github.com/kahaaga/Associations.jl.git"
version = "4.0.0"
version = "4.1.0"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

[![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)
[![](https://img.shields.io/badge/docs-dev_(main)-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)](https://img.shields.io/codecov/c/github/juliadynamics/Associations.jl/main)
[![DOI](https://zenodo.org/badge/135443027.svg)](https://zenodo.org/badge/latestdoi/135443027)

Associations.jl is a package for quantifying associations, independence testing and causal inference.
Expand Down
10 changes: 10 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

From version v4.0 onwards, this package has been renamed to to Associations.jl.

# 4.1

- New association measure: `ChatterjeeCorrelation`.

# 4.0 (package rename)

The package has been renamed from CausalityTools.jl to Associations.jl.

## 3.0 (new major release)

This release contains several breaking changes. Any code from before v3.0 will need
Expand Down
33 changes: 33 additions & 0 deletions docs/refs.bib
Original file line number Diff line number Diff line change
Expand Up @@ -1289,4 +1289,37 @@ @article{Arnhold1999
pages={419--430},
year={1999},
publisher={Elsevier}
}

@article{Chatterjee2021,
title={A new coefficient of correlation},
author={Chatterjee, Sourav},
journal={Journal of the American Statistical Association},
volume={116},
number={536},
pages={2009--2022},
year={2021},
publisher={Taylor \& Francis}
}

@article{Shi2022,
title={On the power of Chatterjee’s rank correlation},
author={Shi, Hongjian and Drton, Mathias and Han, Fang},
journal={Biometrika},
volume={109},
number={2},
pages={317--333},
year={2022},
publisher={Oxford University Press}
}

@article{Dette2013,
title={A Copula-Based Non-parametric Measure of Regression Dependence},
author={Dette, Holger and Siburg, Karl F and Stoimenov, Pavel A},
journal={Scandinavian Journal of Statistics},
volume={40},
number={1},
pages={21--41},
year={2013},
publisher={Wiley Online Library}
}
1 change: 1 addition & 0 deletions docs/src/associations.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ CorrelationMeasure
PearsonCorrelation
PartialCorrelation
DistanceCorrelation
ChatterjeeCorrelation
```

## [Cross-map measures](@id cross_map_api)
Expand Down
30 changes: 29 additions & 1 deletion docs/src/examples/examples_associations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1697,4 +1697,32 @@ 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)
association(est, x, y), association(est, x, z), association(est, x, z, y)
```
```

## [[`ChatterjeeCorrelation`](@ref)](@id example_ChatterjeeCorrelation)

```@example example_ChatterjeeCorrelation
using Associations
using Random; rng = Xoshiro(1234);
x = rand(rng, 120)
y = rand(rng, 120) .* sin.(x)
```

By construction, there will almust surely be no ties in `x`, so we can use the
fast estimate by setting `handle_ties == false`.

```@example example_ChatterjeeCorrelation
association(ChatterjeeCorrelation(handle_ties = false), x, y)
```

If we have data where we know there are ties in the data, then
we should set `handle_ties == true`.

```@example example_ChatterjeeCorrelation
w = rand(rng, 1:10, 120) # there will be some ties
z = rand(rng, 1:15, 120) .* sin.(w) # introduce some dependence
association(ChatterjeeCorrelation(handle_ties = true), w, z)
```



20 changes: 20 additions & 0 deletions docs/src/examples/examples_independence.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ enough evidence in the data to suggest directional coupling.

## [[`SurrogateAssociationTest`](@ref)](@id examples_surrogatetest)

### [Chatterjee correlation](@id example_SurrogateAssociationTest_ChatterjeeCorrelation)

```@example example_SurrogateAssociationTest_ChatterjeeCorrelation
using Associations
using Random; rng = Xoshiro(1234)
n = 1000
x, y = rand(1:50, n), rand(1:50, n)
test = SurrogateAssociationTest(ChatterjeeCorrelation(), nshuffles = 19)
independence(test, x, y)
```

As expected, the test indicates that we can't reject independence. What happens if we introduce
a third variable that depends on `y`?

```@example example_SurrogateAssociationTest_ChatterjeeCorrelation
z = rand(1:20, n) .* y
independence(test, y, z)
```

The test clearly picks up on the functional dependence.

### [Distance correlation](@id example_SurrogateAssociationTest_DistanceCorrelation)

Expand Down
Loading

2 comments on commit 8d1c2e4

@kahaaga
Copy link
Member Author

@kahaaga kahaaga commented on 8d1c2e4 Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/112199

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v4.1.0 -m "<description of version>" 8d1c2e4b4ef2effb00552366b0dad586a8553bbe
git push origin v4.1.0

Please sign in to comment.