[R] Chi square test of proprotions in 2 groups of different sizes

Dimitri Liakhovitski dimitri.liakhovitski at gmail.com
Thu Feb 10 21:43:48 CET 2011


Hello!

Very sorry for a probably very simple question - I looked but did not
find an answer in the archives.
I have a table "counts" (below) that shows counts by Option within
each of my 2 groups. However, my groups have different sizes (N1=255
and N2=68). Table "prop" shows the resulting proportions within each
group.
I would like to compare the proportions in 2 groups using Chi Square
test. However, I am not sure how to do it because chisq.test(counts)
does not take into account the fact that the sizes of the groups are
different.
Any hint is greatly appreciated.
Thank you!
Dimitri

G1counts <- matrix(c(54,76,125), ncol = 1)
G2counts <- matrix(c(14,19,35), ncol = 1)
counts<-cbind(G1counts,G2counts)
colnames(counts)<-c("Group1","Group2");
rownames(counts)<-c("Option1","Option2","Option3")

N1=255
N2=68
Ns=c(N1,N2)

prop1<-G1counts/N1
prop2<-G2counts/N2
prop<-cbind(prop1,prop2)
colnames(prop)<-c("Group1","Group2");
rownames(prop)<-c("Option1","Option2","Option3")

(Ns);(counts);(prop);sum(prop)



More information about the R-help mailing list