-
Notifications
You must be signed in to change notification settings - Fork 1
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: "Error in abs(x) : non-numeric argument to mathematical function" #14
Comments
Thanks for the report! I'm not entirely sure what went wrong without looking at the data (if you want me to help debug this better, you can send the data to jchoe001@gmail.com), but I can at least say that it's not an issue with What's more worrying is the fact that the timewise statistics values are seemingly all
My guess is that the response variable is constant at that timepoint (and possibly at others) and so it's getting flagged internally for being ill-formed. To demonstrate:
I can think about ways of handling this more graciously but you can confirm whether my suspicion is correct first |
Yeah, I guess your intuition is correct. My time variable is uniformly and randomly sampled within the limits, so there's almost always just one observation for a given time point. Is there a way to handle it better than just binning? |
As you guessed, this is likely the problem. The kind of data that CPA expects is one where the timepoints are known (e.g., instead of time being randomly sampled, it should be follow a fixed sampling rate) and there are multiple observations within each timepoint. Essentially, you're fitting a linear model at each time point and collecting the t-statistics of the predictors. As a first check, these timewise linear models must make sense. Without knowing the context of the study, I don't know what kind of assumptions you violate when you choose to bin the data. But indeed, binning will get you closer to the kind of data that CPA expects. In my opinion, binning is actually not a huge problem so I would give it a try - you lose some sensitivity in the temporal resolution but it doesn't bias the test any more than the choice of a threshold. For an example, see the Geller et al. 2020 case study vignette which runs a CPA on data binned by time. |
Thanks! I was thinking that maybe some kind of a moving window approach could be used, or perhaps a weighted regression where weights are based on the temporal distance. Now that I think of it, it should be straightforward to implement a permutation test for this. Anyhow, thanks for your feedback! It's very helpful, and the issue could be closed. |
Great - cheers! |
Hi! Thanks for a nice package! I'm trying to use it for my data with the following specs:
I then do
but get the error "Error in abs(x) : non-numeric argument to mathematical function".
When I do:
I see that the 'time' variable is converted to a character vectir for some reason.
The text was updated successfully, but these errors were encountered: