Re: [R] strange behavior of lchoose in combinatorics problem

2016-06-28 Thread Stefan Evert
Dear Gonçalo, thanks for the additional information – I think I get now what you're trying to do. > On 27 Jun 2016, at 06:35, Gonçalo Ferraz wrote: > > probabilities in lpvec should be <=1, but it is not. The sum is something on > the order of 1.48e-13.” > It is absolutely right that lpvec do

Re: [R] strange behavior of lchoose in combinatorics problem

2016-06-26 Thread Gonçalo Ferraz
Stefan, I am sorry that I wasn’t more careful writing my question. I misrepresented my problem when I wrote “the sum of the probabilities in lpvec should be <=1, but it is not. The sum is something on the order of 1.48e-13.” It is absolutely right that lpvec doesn’t contain probabilities, it con

Re: [R] strange behavior of lchoose in combinatorics problem

2016-06-26 Thread Stefan Evert
Why do you want to do this? Why not simply use Fisher's exact test? N <- 2178 N1 <- 165 N2 <- 331 J <- 97 ct <- rbind(c(J, N1-J), c(N2-J, N-N1-N2+J)) fisher.test(ct) Background explanation: - Your formula computes the log hypergeometric probability for a contingency table as ct above, but with

Re: [R] strange behavior of lchoose in combinatorics problem

2016-06-25 Thread peter dalgaard
> On 25 Jun 2016, at 16:13 , Gonçalo Ferraz wrote: > > PROBLEM: the sum of the probabilities in lpvec should be <=1, but it is not. > The sum is something on the order of 1.48e-13. Um, in which sense is 1.48e-13 not <=1 ??? -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Bus

Re: [R] strange behavior of lchoose in combinatorics problem

2016-06-25 Thread Richard M. Heiberger
Floating point numbers are rounded to 53 significant bits. When you use logs of integers you are using floating point numbers. > .3 + .6 == .9 [1] FALSE > (.3 + .6) - .9 [1] -1.110223e-16 See FAQ 7.31 for more discussion. On Sat, Jun 25, 2016 at 10:13 AM, Gonçalo Ferraz wrote: > Hi, > > I am w

[R] strange behavior of lchoose in combinatorics problem

2016-06-25 Thread Gonçalo Ferraz
Hi, I am working on interactions between animals, studying whether animal 1 is attracted to animal 2 (or vice-versa). I looked for the two animals in N=2178 sampling occasions, finding animal 1 a total of N1=165 times, and animal 2 a total of N2=331 times. In J=97 occasions, I saw both animals