I am running a function (rcompanion::cramerV
) that uses boot.ci
to generate CIs. I am getting the error message:
Error in if (const(t, min(1e-08, mean(t, na.rm = TRUE)/1e+06))) { : missing value where TRUE/FALSE needed
but I'm not sure how to fix it.
It's failing on a specific matrix:
> bad_data <- matrix(c(31, 0, 46, 0, 1, 0), nrow=3, ncol=2)
> bad_data
[,1] [,2]
[1,] 31 0
[2,] 0 1
[3,] 46 0
When I call cramerV
without CIs, it computes fine (yielding V = 1, which I recognise is statistically questionable), but when I call it with CIs e.g. cramerV(bad_data, ci=TRUE)
it gives me that error. Happens regardless of type
of CI specified.
Obviously there are some statistical issues here but that's not my focus; I'm running cramerV
on hundreds of small matrices at once and a couple of outlier results is fine. I just need to know how to get it to work computationally (and maybe return NA
for the CIs in this case).
Edit: I understand that what's happening is the if
condition is evaluating to NA
(per this answer), but I don't know why that's happening or what's going on under the hood with boot.ci
or most importantly how to prevent it.