richarddmorey / BayesFactor

BayesFactor R package for Bayesian data analysis with common statistical models.
https://richarddmorey.github.io/BayesFactor/
131 stars 48 forks source link

Error in ttestBF #92

Closed dberma15 closed 7 years ago

dberma15 commented 7 years ago

Hi,

I'm running a rather large data set (102159 data points) and trying to perform a ttest on it. However, when I run ttestBF(formula=dur~condition, data=data)

I get the following output

Error in if ((n < 1) | (nu < 1)) stop("not enough observations") : 
  missing value where TRUE/FALSE needed

I have checked and there is nothing wrong with the data set. You can run overlapping subsets and it's fine, but you can't seem to run it all together. For example, I ran ttestBF(formula=dur~condition, data=data)[1:90000,] and ttestBF(formula=dur~condition, data=data[8000:102159,]) and they both work. However, running it all together produces an error.

I am able to run a regular ttest without error: 't.test(formula=dur~condition, data=data)`

jonathon-love commented 7 years ago

hi,

can you provide the data to reproduce this? (if you save it as a .csv file with a .txt extension, you should be able to attach it to this issue).

with thanks

dberma15 commented 7 years ago

Here is the data that is producing the error. ttestBFerrorProducingData.txt

richarddmorey commented 7 years ago

I get the (additional), very evocative warning:

Error in if ((n < 1) | (nu < 1)) stop("not enough observations") : 
  missing value where TRUE/FALSE needed
In addition: Warning message:
In n1 * n2 : NAs produced by integer overflow

And it is indeed an integer overflow problem:

ns = table(data$condition)
ns[1] * ns[2]

I'll push a fix soon; should be straightforward.

dberma15 commented 7 years ago

Thanks so much. Please let me know when this is fixed.

richarddmorey commented 7 years ago

This is now fixed in the development version. Follow the instructions for a devtools install (https://github.com/richarddmorey/BayesFactor) if you want to install the fixed version.