-
Notifications
You must be signed in to change notification settings - Fork 23
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 in approxfun(vals, cumsum(tabulate(match(x, vals)))/(n + 1), method = "linear", : need at least two non-NA values to interpolate #195
Comments
OK, for future reference, I paste the reproducible example here
|
The problem is there are several data points in the simulation that produce zero variance. You can see this via
I think other users had this problem before. I guess the best way to deal with it would be to calculate the residual to NA instead of throwing an error. I should have implemented that before and will do so now! |
After a bit of thinking, I guess it should be evaluate to U[0,1] instead of NA. I have implemented this now, and it seems to work OK, will push this to master, if you install the development version this should work now. |
Note to self - this needs a small correction to check for < and > |
Hi, This appears to be an issue stemming from the function
This approach has some weirdness with regard to numerical precision, but if that is relevant to the data-set, than R is probably not the right platform anyway. Also, weirdly, both this and the original function divides by n+1 which leads to F(max(x)) = 1-1/(n+1). This seams to be intentional but i'm not all that convinced by the overall setup. Here are my tests:
The default ecdf function behaves precisely as expected, but is not symmetric or anything, so perhapps one could use something like (ecdf(x) + ecdf(x+e))/2, sadly this doesn't work on it's own, so a bit additional effort would have to be invested.
|
Hi Lukas, I agree with not calling DHARMa.ecdf in the PIT calculation, this is indeed unnecessary. About your modifications - this may very well be a good idea, but at the moment my priority is to correct the current errors in DHARMa asap. I will thus open a new ticked for the ecdf and move this to the next commit. I just modified the code, the issue above should be solved for a standard normal user! |
Hi all, I just closed issue #286 but have some questions about the fix that was implemented here (which appears to be the same issue). Hopefully my questions are helpful and not annoying, and thanks for your attention. My interpretation of PIT residuals is that:
This is true even in instances when
I believe these three are a complete set of possible outcomes when var=0, and my interpretation of the proper fix appears to differ from some of the proposals discussed in the thread, i.e., using U(0,1) or fixing a value of 0 for all three cases when any simulated variance is zero (where by my logic these solutions are appropriate for some but not all such cases). Do y'all want to discuss further here? If yes, are you willing to summarize what the ultimate fix was that was implemented? |
Hi, there was no need to apologize in the original thread, i just felt awkward answering without a preface. Anyway, this issue was resolved by changing the PIT-algorithm to no longer use the custom ecdf. You can find the current implementation here: Lines 87 to 93 in bcf9e1e
I agree with your interpretation and i'm quite sure that we implemented that behavior. Plus, if all simulations and the observed value are identical the residual is U[0, 1] distributed. The discussion on this issue is hard to follow as it simultaneously toke place in #197, which had a different focus. Please feel free to double check the behavior of the current implementation. It can't hurt. |
Hi @James-Thorson-NOAA - as @Istalan said, my reading is that the code is implementing the behavior that you describe. |
I agree, thanks for pointing me to the code; the snippet appears to do what I describe (and previous and ongoing use testing doesn't indicate any problems either). |
Heyho,
I am getting the following error for one specification of a GLMM:
I tried playing around a bit,
For context: I am working on some guidelines on how to best analyze a particular type of data, so I am looking into the "best" model specification from different perspectives, one of which are to what extent they meet the assumptions. So it would be extremely useful for me to be able to compare all relevant specifications.
Here is a (trimmed) version of the analyses (includes simulation of data), including the four cases I am mentioning:
https://github.com/b-jorges/Power-Analyses-Psychophysics/blob/master/Sample%20Code.R
Do you see any simple fix for that?
Thanks,
Björn
Ps: Awesome package!
The text was updated successfully, but these errors were encountered: