[R] chi square
Federico Calboli
f.calboli at ucl.ac.uk
Fri Feb 28 16:21:02 CET 2003
Hi All,
I woul like to ask you a couple of questions on chisq.test.
First, I have 40 flies, 14 males and 26 females and I want to test for an a
priori hypothesis that the sex ratio is 1:1
sex<-c(14,26)
pr<-c(1,1)/2
chisq.test(se, p=pr, correct=TRUE)
Chi-squared test for given probabilities
data: sex
X-squared = 3.6, df = 1, p-value = 0.05778
If my calculations are correct, this is the Chi-square without the Yates
correction. The value after correction would be X-squared = 3.02. How do I
apply Yates correction?
Second, I want to do an homogeneity test on seed colour segregation. I have
green and yellow seed in an a priori expected segregation ration of 3:1.
green<-c(85,130,110,107,70,45,30)
yellow<-c(26,41,51,35,36,16,11)
chisq.test(rbind(green,yellow))
Pearson's Chi-squared test
data: rbind(verdi, gialli)
X-squared = 6.2672, df = 6, p-value = 0.3939
That's fine. Now I want to tell chisq.test that I have my a priori expected
frequncies:
prob.green<-rep(3/4,7)
prob.yellow<-rep(1/4,7)
chisq.test(rbind(green,yellow), p=rbind(prob.green,prob.yellow))
Pearson's Chi-squared test
data: rbind(verdi, gialli)
X-squared = 6.2672, df = 6, p-value = 0.3939
Exactly the same thing as before! How do I tell chisq.test to take my a
priori assumption into account? on paper I would calculate my seven X^2 on
my expectations, sum them and then subtracted the X^2 done on the sum. the
resulting X^2 of homogeneity is 6.6 on 6 df. Is my calculation on paper
sensible anyway?
Cheers,
Federico Calboli
=========================
Federico C.F. Calboli
Department of Biology
University College London
Room 327
Darwin Building
Gower Street
London
WClE 6BT
Tel: (+44) 020 7679 4395
Fax (+44) 020 7679 7096
f.calboli at ucl.ac.uk
More information about the R-help
mailing list