merliseclyde / BAS

BAS R package https://merliseclyde.github.io/BAS/
https://merliseclyde.github.io/BAS/
GNU General Public License v3.0
41 stars 16 forks source link

phi1 function returns NA or Inf for large values of x #55

Closed merliseclyde closed 2 years ago

merliseclyde commented 2 years ago

Describe the bug For large values of the Wald statistic (typical with large n) the current implementation of the Phi1 function in BAS returns NA or Inf due to overflow in the exponential function. This impacts Bayes factor calculations with several prior distributions in bas.glm, such as the hyper-g/n

To Reproduce Steps to reproduce the behavior:

BAS::phi1(1, 2, 1.5, 1000, 1/100)

Reported by Daniel Heeman

merliseclyde commented 2 years ago

Fixed as of BS 1.6.2

Note

BAS::phi1(1, 2, 1.5, 1000, 1/100, log=FALSE)

still returns Inf

Use

BAS::phi1(1, 2, 1.5, 1000, 1/100, log=TRUE)

as the result is greater that the largest double for exponentiating