You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Short expansion of conditional mutual information (#387)
* wip...
* Reorganize into separate file for the SECMI test
* tests, docs
* changelog + version
* Slightly reorganize tests
* fix tests
* docs
* no need to store shuffles
* examples
* fix deprecated syntax
* reproducible tests
* Add cross-references
* documentation example for SECMI
* Actually show docstrings
* docstring
* docstring
* add relevant imports
* reproducible tests
* better description
* Fix implementation for mu < 0
* CI badge for main branch only
* Update changelog and version
* Increase sample size to have enough points to get consistent results
* better tests for secmi
* a comment explaining the marginal selection
* Add min/max variables for SECMI
* Use SECMITest in oce tests
### [[`JointProbabilities`](@ref) with [`CodifyVariables`](@ref) and [`ValueBinning`](@ref)](@id example_ShortExpansionConditionalMutualInformation_JointProbabilities_CodifyVariables_ValueBinning)
1099
+
1100
+
```@example
1101
+
using Associations
1102
+
using Test
1103
+
using Random; rng = Xoshiro(1234)
1104
+
n = 20
1105
+
x = rand(rng, n)
1106
+
y = randn(rng, n) .+ x .^ 2
1107
+
z = randn(rng, n) .* y
1108
+
1109
+
# An estimator for estimating the SECMI measure
1110
+
est = JointProbabilities(SECMI(base = 2), CodifyVariables(ValueBinning(3)))
Copy file name to clipboardExpand all lines: docs/src/examples/examples_independence.md
+51-1Lines changed: 51 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -469,4 +469,54 @@ connecting `x` and `z`.)
469
469
independence(test, x, z, y)
470
470
```
471
471
472
-
The test verifies our expectation.
472
+
The test verifies our expectation.
473
+
## [[`SECMITest`](@ref)](@id example_SECMITEST)
474
+
475
+
## [[`JointProbabilities`](@ref) estimation on numeric data](@id example_SECMITEST_JointProbabilities_CodifyVariables_ValueBinning)
476
+
477
+
```@example example_SECMITEst
478
+
using Associations
479
+
using Test
480
+
using Random; rng = Xoshiro(1234)
481
+
n = 25
482
+
x = rand(rng, n)
483
+
y = randn(rng, n) .+ x .^ 2
484
+
z = randn(rng, n) .* y
485
+
486
+
# An estimator for estimating the SECMI measure
487
+
est = JointProbabilities(SECMI(base = 2), CodifyVariables(ValueBinning(3)))
488
+
test = SECMITest(est; nshuffles = 19)
489
+
```
490
+
491
+
When analyzing ``SECMI(x, y | z)``, the expectation is to reject the null hypothesis (independence), since `x` and `y` are connected, regardless of the effect of `z`.
492
+
493
+
```@example example_SECMITEst
494
+
independence(test, x, y, z)
495
+
```
496
+
497
+
We can detect this association, even for `n = 25`! When analyzing ``SECMI(x, z | y)``, we
498
+
expect that we can't reject the null (indepdendence), precisely since `x` and `z` are *not*
499
+
connected when "conditioning away" `y`.
500
+
501
+
```@example example_SECMITEst
502
+
independence(test, x, z, y)
503
+
```
504
+
505
+
## [[`JointProbabilities`](@ref) estimation on categorical data](@id example_SECMITEST_JointProbabilities_CodifyVariables_UniqueElements)
506
+
507
+
Note that this also works for categorical variables. Just use [`UniqueElements`](@ref) to
508
+
discretize!
509
+
510
+
```@example example_SECMITest_categorical
511
+
using Associations
512
+
using Test
513
+
using Random; rng = Xoshiro(1234)
514
+
n = 24
515
+
x = rand(rng, ["vegetables", "candy"], n)
516
+
y = [xᵢ == "candy" && rand(rng) > 0.3 ? "yummy" : "yuck" for xᵢ in x]
517
+
z = [yᵢ == "yummy" && rand(rng) > 0.6 ? "grown-up" : "child" for yᵢ in y]
0 commit comments