Re: [R] 2 x 3 Probability under the null

2011-10-27 Thread Ted Harding
On 27-Oct-11 04:09:46, Jim Silverton wrote:
 I have a 2 x 3 matrix called snp and I want to compute the following
 probability:
 
 choose(sum(snp[,1]), snp[1,1]) * choose(sum(snp[,2]), snp[1,2]) *
 choose(sum(snp[,3]), snp[1,3])/choose(sum(snp), sum(snp[1,]))
 
 but I keep getting Infs and NaNs. Is there a function that can do this
 in R?
 -- 
 Thanks,
 Jim.

Since 1/0 -- Inf, and 0/0 -- NaN, it seems likely that your
data lead to zero denominators. However, true diagnosis needs
to see what your data really are. What is a typical 2x3 matrix
that gives such results?

If this guess is correct, then no possible function in R can
resolve the problem! For data where the problem does not arise,
then you can of course write your own function to implement
your code above for an arbitrary 2x3 matrix.

Hoping this helps,
Ted.


E-Mail: (Ted Harding) ted.hard...@wlandres.net
Fax-to-email: +44 (0)870 094 0861
Date: 27-Oct-11   Time: 07:32:30
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] 2 x 3 Probability under the null

2011-10-27 Thread Duncan Murdoch

On 11-10-27 12:09 AM, Jim Silverton wrote:

I have a 2 x 3 matrix called snp and I want to compute the following
probability:

choose(sum(snp[,1]), snp[1,1]) * choose(sum(snp[,2]), snp[1,2]) *
choose(sum(snp[,3]), snp[1,3])/choose(sum(snp), sum(snp[1,]))

but I keep getting Infs and NaNs. Is there a function that can do this in R?





Work in the log scale.  You're probably getting overflows.  lchoose() 
calculates the log of choose().


Duncan Murdoch

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] 2 x 3 Probability under the null

2011-10-26 Thread Jim Silverton
I have a 2 x 3 matrix called snp and I want to compute the following
probability:

choose(sum(snp[,1]), snp[1,1]) * choose(sum(snp[,2]), snp[1,2]) *
choose(sum(snp[,3]), snp[1,3])/choose(sum(snp), sum(snp[1,]))

but I keep getting Infs and NaNs. Is there a function that can do this in R?



-- 
Thanks,
Jim.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.