-
Notifications
You must be signed in to change notification settings - Fork 14
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
Negative tau2 error in DerSimonianLaird random effects estimation #40
Comments
What behavior would you like it to have? Return NaNs at voxels where the input data contained NaNs? |
I think returning NaNs at voxels where the input data contained all zeros or NaNs would be good. Unless zero would be better when all studies have zeros at a given voxel? I think that methods like |
Okay, I'll have it return NaNs. Might be a while before I can get to it though, so feel free to open a PR if you need this urgently. |
I kept digging and found out that it's not the all-zero voxels that are causing the problem. Sorry about the mis-reported bug! I've isolated the voxel that consistently raises the exception, but I can't figure out what is causing it. To replicate (on my laptop at least): import numpy as np
from pymare.stats import q_profile
y = np.array([0.0000000e+00, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00, -5.2165329e-01, 7.4963748e-01, 3.3219385e-01, -1.2351226e+00, 1.7527617e+00, -3.0110748e+00, 1.0946554e+02, -4.8926108e-02, 0.0000000e+00, 0.0000000e+00, 0.0000000e+00, -6.2120113e+01, -2.8613630e+01, -1.2308966e+01, 5.3221474e+00, 0.0000000e+00, -9.2870388e+00])
v = np.array([0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 5.54480810e-01, 1.21734442e-01, 2.25415160e-01, 1.74327830e+00, 6.00752247e-01, 1.43908420e+00, 3.25888647e+03, 4.66549950e+01, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 2.91479907e+03, 2.15909521e+03, 2.17931152e+03, 1.63775589e+02, 0.00000000e+00, 1.01077698e+02])
X = np.array([[1.], [1.], [1.], [1.], [1.], [1.], [1.], [1.], [1.], [1.], [1.], [1.], [1.], [1.], [1.], [1.], [1.], [1.], [1.], [1.], [1.]])
alpha = 0.05
q_cis = q_profile(y=y, X=X, v=v, alpha=alpha) The behavior for all-zero voxels seems to be that tau2 ends up NaN, but the confidence intervals end up at their respective bounds (i.e., [0, 100]). I do think those should be NaNs, but that's more an enhancement to request than a bug to report. I will update this issue and open a new one for the NaN-handling soonish. |
Setting aside the issue for this particular voxel (which we do need to get to the bottom of), I don't recommend treating voxels with missing data for studies as if the estimates and variances are (Alternatively, you could list-wise delete the missing studies, so that PyMARE gets only complete data. But that would be very misleading to the end user, because they'd have no way of knowing that different voxels could be based on different studies. So I'd recommend just erring on the side of caution and dropping all voxels that don't have complete data everywhere.) |
I've opened #42 to continue discussion of handling missing data, and will change the title and summary for this issue to match the bug of unknown cause. |
It looks like this is an optimization problem—scipy's What I'm going to do for the moment is pick a starting value based on the data, and hopefully that will at least reduce the number of failures of this sort we get. I don't want to explicitly handle exceptions just yet, as I want to get a sense of how rare these failure are in practice before we take that step. But if this crops up again, as seems likely, I think we're going to have to just set |
@tsalo on a semi-related note, getting CIs for the tau^2 estimate via |
I'm totally fine not including CIs in NiMARE- at least unless users start requesting them (though I doubt that will happen any time soon). Thanks for the heads up. |
Updated summary
There is a bug in Estimators wherein, during random-effects stats estimation,
tau2
may drop below zero and raise an exception. I don't know what's causing this, but for documentation of the actual bug, see #40 (comment).To replicate (on my laptop):
Original post
I tried running the
DerSimonianLaird
estimator on the 21-pain dataset we use in NiMARE to test IBMA methods. There is apparently some mismatch between NiMARE's default brain mask and the maps in the Dataset, so some voxels have all zeroes for both beta and varcope maps. These zero voxels lead to divide-by-zero issues in the estimator, leading to NaNs in thetau2
estimates and an exception when trying to get RE stats.For an example, see this notebook.
The text was updated successfully, but these errors were encountered: