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

trend analysis - computation of δ (balanced distance of diagonal) #167

Closed
schlichtanders opened this issue Jan 9, 2025 · 11 comments · Fixed by #168
Closed

trend analysis - computation of δ (balanced distance of diagonal) #167

schlichtanders opened this issue Jan 9, 2025 · 11 comments · Fixed by #168
Labels
clarity Will increase clarity of source code or high level API question

Comments

@schlichtanders
Copy link

schlichtanders commented Jan 9, 2025

in

δ seems to be defined by comparing the current dimension with the "mean dimension", analogous to how the tau_recurrence value of the current dimension is compared to the mean recurrence value in

numerator += δ*(rr_τ[d] - mean_rr)

However the mean is taken from a:b only

mean_rr = mean(@view rr_τ[a:b])

so shouldn't it be

δ = d - (a+b)/2

?

@Datseris
Copy link
Member

Datseris commented Jan 9, 2025

@felixcremer do you have any idea? @schlichtanders sorry, its been so long since I've done any meaningful science with RQA that I don't have the expertise to answer right away, I would need more background information.

@Datseris
Copy link
Member

Datseris commented Jan 9, 2025

Oh perhaps @pucicu has an idea as well?

@Datseris Datseris added question clarity Will increase clarity of source code or high level API labels Jan 9, 2025
@schlichtanders
Copy link
Author

schlichtanders commented Jan 9, 2025

I followed the literatur, and this is a standard computation of the slope of a linear regression.

This indeed requires the correct mean

See for instance https://en.wikipedia.org/wiki/Ordinary_least_squares#Simple_linear_regression_model

@heliosdrm
Copy link
Collaborator

The current implementation is based on the formula given here: http://www.recurrence-plot.tk/rqa.php

But it's true that that formula considers no Theiler window, (i.e. a=1), so it might be necessary to adapt it. However, even in that case it shouldn't be

δ = d - (a+b)/2

but

δ = d - (b+theiler)/2

(a and theiler differ by 1)

@pucicu
Copy link
Contributor

pucicu commented Jan 10, 2025 via email

@schlichtanders
Copy link
Author

schlichtanders commented Jan 10, 2025

Here https://www.nsf.gov/pubs/2005/nsf05057/nmbs/nmbs.pdf (search for TREND) the trend is defined as the slope of a linear regression between diagonal offset and percentage of local recurrence, which I find quite intuitive as a measure.

@pucicu
Copy link
Contributor

pucicu commented Jan 10, 2025 via email

@pucicu
Copy link
Contributor

pucicu commented Jan 10, 2025 via email

@Datseris
Copy link
Member

Right, so what's the status now with this issue? Is there a change that should be done, or should it be closed?

@heliosdrm
Copy link
Collaborator

heliosdrm commented Jan 11, 2025

I would fix trend as I suggested above

δ = d - (b+theiler)/2

So that it is balanced with theiler windows, keeping the same result as the formula published in recurrence-plot.tk when theiler==0, as assumed there.
I'm doing the corresponding PR.

@pucicu
Copy link
Contributor

pucicu commented Jan 11, 2025 via email

Datseris added a commit that referenced this issue Jan 11, 2025
* Fix computation of trend according to #167

* fix test result of trend

* fix test results of trend

* Update CHANGELOG.md

* Update docstring of `trend`

* Update CHANGELOG.md

---------

Co-authored-by: George Datseris <datseris.george@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarity Will increase clarity of source code or high level API question
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants