Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap based nonuniform embedding (BBNUE) estimator #80

Merged
merged 6 commits into from
Dec 10, 2021

Conversation

kahaaga
Copy link
Member

@kahaaga kahaaga commented Dec 8, 2021

A version of the NUE estimator from Montalto, A.; Faes, L.; Marinazzo, D. MuTE: A MATLAB toolbox to compare established and novel estimators of the multivariate transfer entropy. PLoS ONE 2014, 9, e109462.

Project.toml Show resolved Hide resolved
Comment on lines 18 to 26
"""
transferentropy(source, target, [cond], est::BBNUE; q = 0.95, η = 1,
nsurr = 100, uq = 0.95,
include_instantaneous = true,
method_delay = "ac_min",
maxlag::Union{Int, Float64} = 0.05
) → te, js, τs, idxs_source, idxs_target, idxs_cond

Estimate transfer entropy using the [`BBNUE`](@ref) estimator, which uses a bootstrap-based
Copy link
Member

Choose a reason for hiding this comment

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

I vote that all of this docstring is in BBNUE instead. "Polluting" the transferentropy docstring with so much details about a specific method isn't ideal for a user. The API is clear that est is used in transferentropy, there is no gain in highlighting here what transferentropy does with this specific method. Instead, better to highlight it at BBNUE.

@Datseris
Copy link
Member

Datseris commented Dec 9, 2021

@kahaaga I am not familiar with this method and I won't have time to read the paper to get the necessary amount of familiarity. Thus, I cannot review the actual source code but only the documentation. Just letting you know in advance.

`source(t) → target(t)` are allowed.

In this implementation, the maximum lag for each embedding variable is determined using `estimate_delay`
from `DelayEmbeddings.jl`. The keywords `method_delay` (default is "ac_min") controls the method
Copy link
Member

Choose a reason for hiding this comment

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

You either have DelayEmbeddings or DelayEmbeddings.jl without code inline.

Comment on lines +56 to +64
## Returns

A 6-tuple is returned, consisting of:
- `te`: The computed transfer entropy value. If no relevant variables were selected, then `te = 0.0`.
- `js`: The indices of the selected variables. `js[i]` is the `i`-th entry in the array `[idxs_source..., idxs_target..., idxs_cond...,]`.
- `τs`: The embedding lags of the selected variables. `τs[i]` corresponds to `js[i]`.
- `idxs_source`: The indices of the source variables.
- `idxs_target`: The indices of the target variables.
- `idxs_cond`: The indices of the conditional variables (empty if `cond` is not given).
Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see. I guess that's a reason to explain this in the docstring of transfer entropy. Okay, then I think the best thing to do is to create a new function alltogether. I think it is not the best idea to use the same name transferentropy for such a massively different return signature.

It is probably more intuitive to make a new function and put it in the docs in the same section as BBNAU.

@kahaaga
Copy link
Member Author

kahaaga commented Dec 9, 2021

@kahaaga I am not familiar with this method and I won't have time to read the paper to get the necessary amount of familiarity. Thus, I cannot review the actual source code but only the documentation. Just letting you know in advance.

@Datseris No worries! I don't expect you to learn a new method just for a PR here. You input on the documentation and interface continues to be very valuable.

Ah, I see. I guess that's a reason to explain this in the docstring of transfer entropy. Okay, then I think the best thing to do is to create a new function alltogether. I think it is not the best idea to use the same name transferentropy for such a massively different return signature.
It is probably more intuitive to make a new function and put it in the docs in the same section as BBNAU.

I agree. I hesitated a bit by re-using transferentropy. Maybe it could be an idea in the future to use some like optim_transferentropy(source, target, [cond], est) as an analogue to transferentropy(source, target, [cond], est) for estimators that use some optimization procedure?

There are several other similar methods that optimize the embedding that I'm implementing at the moment. However, I'm not entirely sure if they would all return the same information yet. Thus, I agree, and think I will just make a method-specific function bbnue(source, target, [cond], est) instead of transferentropy(source, target, [cond], est::BBNUE).

Thanks for the input!

@codecov-commenter
Copy link

codecov-commenter commented Dec 9, 2021

Codecov Report

Merging #80 (2685b32) into master (4d5f6ba) will increase coverage by 5.30%.
The diff coverage is 92.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #80      +/-   ##
==========================================
+ Coverage   72.35%   77.65%   +5.30%     
==========================================
  Files           8       10       +2     
  Lines         340      461     +121     
==========================================
+ Hits          246      358     +112     
- Misses         94      103       +9     
Impacted Files Coverage Δ
src/transferentropy/interface.jl 75.00% <ø> (ø)
src/transferentropy/autoutils.jl 92.10% <92.10%> (ø)
src/transferentropy/bbnue.jl 100.00% <100.00%> (ø)
src/transferentropy/transferoperator.jl 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4d5f6ba...2685b32. Read the comment docs.

@Datseris
Copy link
Member

Datseris commented Dec 9, 2021

yeah bbnue(...) seems best

Copy link
Member

@Datseris Datseris left a comment

Choose a reason for hiding this comment

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

Don't forget to increment minor version in Project.toml, as this is an additional feature.

@kahaaga kahaaga merged commit 101130e into master Dec 10, 2021
@Datseris Datseris deleted the automated_embedding_finder branch December 10, 2021 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants