SugiharaLab / rEDM

Applications of Empirical Dynamic Modeling from Time Series
Other
117 stars 43 forks source link

make_block producing zeros instead of NaN #48

Closed jestupinanm closed 3 years ago

jestupinanm commented 3 years ago

When using the function make_block to make my own embeddings, if I use a tau different than (the default) -1, I get a series of zeros that I think should be NaN

Eg. if I do

head(make_block(Lorenz5D, "V1", tau = -2))

I get as a result

-- V1(t-0) V1(t-1) V1(t-2)
1 2.4873 NaN NaN
2 3.5108 0.0000 NaN
3 4.1666 2.4873 0.0000
4 4.4836 3.5108 0.0000
5 4.5246 4.1666 2.4873
6 4.3996 4.4836 3.5108

note that also the title for each column is only (t+n) and not (t+n*tau)

Is this also the behavior if I try to use different tau in the simplex function?

Thank you!, Juan

SoftwareLiteracy commented 3 years ago

Thank you Juan. I agree the behavior in terms of column labeling and 0's instead of NaN is wrong when tau is not +-1.

The shifting of data rows is correct. In Simplex and others, data rows with NaN (or improper 0's) are not included in the library, so numerically the EDM results are correct.

I'm adding this bug to the defect list to be fixed. Thank you!

SoftwareLiteracy commented 3 years ago

fyi: This has been addressed in version 1.8.2. An installable image is here.

> head( make_block( Lorenz5D, "V1", tau = -2 ) )
  V1(t-0) V1(t-2) V1(t-4)
1   2.487     NaN     NaN
2   3.511     NaN     NaN
3   4.167   2.487     NaN
4   4.484   3.511     NaN
5   4.525   4.167   2.487
6   4.400   4.484   3.511

The new API MakeBlock provides more control over the returned block with options to specifiy the number of embedding dimensions (E) and to delete partial data rows.

jestupinanm commented 3 years ago

I just had time to test this. Thank you, now It works well :) So, in general, do you suggest using MakeBlock instead of make_block? the same for the other functions like CCM vs ccm, Simplex vs simplex, ...?

SoftwareLiteracy commented 3 years ago

Yes. As mentioned in the docs, it is recommended to use the new API when possible. Simplex, SMap, CCM, ... they are direct calls to the underlying cppEDM. The legacy API (s_map, block_lnlp,...) are wrappers to these calls, that have not been fully vetted against the old versions of rEDM.