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

Error for certain scatter plots #4

Open
uschiLaa opened this issue Sep 17, 2021 · 9 comments
Open

Error for certain scatter plots #4

uschiLaa opened this issue Sep 17, 2021 · 9 comments

Comments

@uschiLaa
Copy link
Contributor

Sometimes the triangulation (?) throws errors, maybe to do with discreetness? Simple example is

calc_scags(anscombe$x1, anscombe$x4)
Fehler in tri.mesh(X) : NA/NaN/Inf in externem Funktionsaufruf (arg 3)
Zusätzlich: Warnmeldungen:
1: In tri.mesh(X) : success: collinearities reduced through jitter
2: In tri.mesh(X) : dataset started with 3 colinear points, jitter added!

But I saw the same error with more complex scatter plots too.

This will throw the calc_scags_wide function, so maybe catch and return NA instead?

@sa-lee
Copy link

sa-lee commented Sep 19, 2021

I can't reproduce the error but do get the warning here. I think the warning makes sense but should most likely be supressed. Does the triangulation make sense in cases like this where one variable really is discrete?

@uschiLaa
Copy link
Contributor Author

Hm, maybe it just happens on my machine then? It occurs for me when running calc_scags_wide on the features from feasts rather than tsfeatures. In any case I think the calc_scags_wide function should still return results for everything else if it fails for one (or a few) combinations of variables, rather than exiting with an error (though the error message is super useful to understand what is going on!).

Could you (or someone else) check if you can run this code? (It seems to me the same issue I get with the anscombe data as well)

library(feasts)
get_features <- function(ts_in){
features(as_tsibble(ts_in), value, feature_set("feasts"))
}
feats_birdsong <- purrr::map_dfr(cets_birdsong, get_features)
cassowaryr::calc_scags_wide(feats_birdsong)

Plotting the two features that cause the error for me would be:
ggplot(feats_birdsong, aes(zero_run_mean, spikiness)) +
geom_point()

@dicook
Copy link
Contributor

dicook commented Sep 23, 2021

this should be fixed now

@dicook
Copy link
Contributor

dicook commented Sep 23, 2021

Nope, it fixed the problem with Anscombe but still exists for the birdsong example

@dicook
Copy link
Contributor

dicook commented Sep 23, 2021

problem is in sc_convex:

sc_convex(feats_birdsong$zero_run_mean, feats_birdsong$spikiness)
Error in arcs[j, ] <- c(compl[ind[which], 1], compl[ind[which], 2], compl[ind[which], :
replacement has length zero
In addition: Warning message:
In min(compl[ind[compl[ind, "r"] > 0], "r"]) :
no non-missing arguments to min; returning Inf

@dicook
Copy link
Contributor

dicook commented Sep 23, 2021

and skinny:

sc_skinny(feats_birdsong$zero_run_mean, feats_birdsong$spikiness)
Error in arcs[j, ] <- c(compl[ind[which], 1], compl[ind[which], 2], compl[ind[which], :
replacement has length zero
In addition: Warning message:
In min(compl[ind[compl[ind, "r"] > 0], "r"]) :
no non-missing arguments to min; returning Inf

@dicook
Copy link
Contributor

dicook commented Sep 23, 2021

This is fixed now. Would be good for someone to check it.

@uschiLaa
Copy link
Contributor Author

The individual functions seem to all work now, but I still get errors when going through the wrapper function, e.g.

sc_splines(feats_birdsong$zero_run_mean, feats_birdsong$spikiness)
[1] 0.0985566
calc_scags(feats_birdsong$zero_run_mean, feats_birdsong$spikiness, scags = c("splines"))
Fehler in tri.mesh(X) : NA/NaN/Inf in externem Funktionsaufruf (arg 2)

And of course also when going via calc_scags_wide

@uschiLaa
Copy link
Contributor Author

Most issues have been fixed, but I still get an error with the feats_birdsong data for combinations with only two unique points (so only two points after removing duplicates), this happens for ndiffs vs kpss_pvalue. Maybe the solution could be to remove duplicates as the first thing in the original_and_robust function and return NULL if there are less than three points left, then check that we still have >= 3 points again after outlier removal. By returning NULL from this function we currently record all scagnostics values as NA in the result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants