# Chi-square test with replicate nested

I have a question about how to analyse count data with replicates nested in each treatment. For example, imagine temperature can influence the sex ratio of mosquito larva emerged from eggs. I have two temperatures, 27 degree and 37 degree. For each temperature treatment, two replicates are used, eg. in temperature 27, there are 32 male larva and 18 female larva for the first replicate; and 30 male/ 20 female for the second replicate. My main purpose is to determine if there is significant difference of sex ratio between the two temperature regimes.

Clearly, if there is only one replicate for each treatment, chi-square test would be the best choice to analyse the data. But with the two replicates, I don't know what should do? Merge two replicates in each treatment as one? I don't think so.

I don't know what software you are using, but I will be using R to show how to perform a 2x2 table proportion test. First recreate your table, merge the sexes in each temperature

dat=matrix(c(62,38,46,54),nrow=2,byrow=T)
dat
[,1] [,2]
[1,]   62   38
[2,]   46   54


And the test

prop.test(dat)

2-sample test for equality of proportions with continuity correction

data:  dat
X-squared = 4.529, df = 1, p-value = 0.03333
alternative hypothesis: two.sided
95 percent confidence interval:
0.01364509 0.30635491
sample estimates:
prop 1 prop 2
0.62   0.46

• I am also using R. My problem is how to deal with the two replications in each treatment. In your reply, you simply add them together to create one 2X2 table. I am wondering if there are other more reasonable method . – Even Guan Jan 9 at 10:30
• @EvenGuan if you are worried about the replicates, you could use generalized linear models with replicates as random effects to account for the replicate variablity. – user2974951 Jan 9 at 10:41