Contingency tests in R, Error with large numbers
0
0
Entering edit mode
@gibbons-john-g-6044
Last seen 9.6 years ago
Hello, I am fairly new to R though, so please forgive me if this is a fairly easy solution. I am trying to perform multiple Fisher's Exact tests or Pearson's Chi-squared contingency tests from a datamatrix in which data from each row is data for an independent test. My data is formatted as such: Quote: AAA 75533 4756922556 88210 6715122129 BBB 14869 4756983220 16384 6715193955 CCC 7230 4756990859 8559 6715201780 DDD 18332 4756979757 23336 6715187003 EEE 14733 4756983356 16826 6715193513 FFF 2918 4756995171 3433 6715206906 GGG 3726 4756994363 4038 6715206301 HHH 6196 4756991893 7011 6715203328 III 7925 4756990164 9130 6715201209 JJJ 1434 4756996655 1602 6715208737 Where the 1st column is the identifier, the 2nd column = observations 1, the 3rd column = background counts 1, the 4th column = observations 2 and the 5th column = background counts 2. As you'll notice, the observed frequencies are MUCH larger than the background frequencies. I am loading my data like this: > data=read.table("My.File", header=FALSE) And I am looping through each row to perform a test like this: > pvalues=c("pvalue") > for(i in 1:10){ + datamatrix=matrix(c(as.integer(data[i,2:5])),nrow=2) + fisherresult=fisher.test(datamatrix) + pvalues=cbind(pvalues,fisherresult[1]) + } Here is the Error I am Getting: Error in fisher.test(datamatrix) : all entries of 'x' must be nonnegative and finite In addition: Warning messages: 1: In matrix(c(as.integer(data[i, 2:5])), nrow = 2) : NAs introduced by coercion 2: In matrix(c(as.integer(data[i, 2:5])), nrow = 2) : NAs introduced by coercion When I replace the large number in the 3rd and 5th column with smaller numbers, the statistical calculation works fine. Any ideas? Any help would be GREATLY appreciated! Thanks, John ------------------------------------------ John G Gibbons, Ph.D. Postdoctoral Research Fellow Lemos Lab Harvard School of Public Health Department of Environmental Health 665 Huntington Ave Building 2 Boston, Massachusetts 02115 Phone: 617.432.4991 Email: jgibbons at hsph.harvard.edu http://www.hsph.harvard.edu/john-gibbons/
• 1.1k views
ADD COMMENT

Login before adding your answer.

Traffic: 615 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6