[GenABEL-dev] Best way to 'round' small floats

L.C. Karssen lennart at karssen.org
Mon May 19 16:06:49 CEST 2014


Dear list,

While working on adding p-values to the ProbABEL output I ran into the
fact that (at least in the checks) we end up with small negative chi^2
values (e.g. -1.14e-13) for some models (e.g. dominant). Of course this
shouldn't happen, but my guess is it's a numerical problem caused by
subtracting the two likelihoods for the Likelihood Ratio Test.

I'd like to add a bit of code like this to mitigate this issue:

  if (chi2 < 0 && abs(chi2) < EPS) { chi2 = 0 }

with EPS set to e.g. 1e-9.
This won't harm any analysis, since we're only interested in chi^2
values away from zero, but I was wondering if there is a more
appropriate way to do this.


Thanks,

Lennart.
-- 
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
L.C. Karssen
Utrecht
The Netherlands

lennart at karssen.org
http://blog.karssen.org
GPG key ID: A88F554A
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: OpenPGP digital signature
URL: <http://lists.r-forge.r-project.org/pipermail/genabel-devel/attachments/20140519/7e1fb153/attachment.sig>


More information about the genabel-devel mailing list