[R] how to use chi-square to test correlation question

genomenet at gmail.com genomenet at gmail.com
Wed Jun 27 17:51:21 CEST 2007


Hi There,

There are 300 boy students and 100 girl students in a class. One interesting question is whether 
boy is smarter than girl or not.

first given the exam with a difficulty level 1, the number of the student who got A is below
31 for boy, 10 for girl.

Then we increase the difficulty level of the exam to level 2, the number of the student who got A is below
32 for boy, 10 for girl.

We did this 10 times, we got the following table
                                    score
gender  level1 level2 levle3 level4 level5 level6 level7 level 8 level9 level10
boy       31     32      33     34     35     36     37     38     39      40
girl      10     10      10     10     10     10     10     10     10      10


My question is how to use chi-square test to test if score is independent of gender.
That is whether boys is significantly smarter than girls.

I used a chisquare test to do this.
The null hypothesis is score is not correlated with gender. and we can also say
the null hypothesis is boys are the same smart as girls.
the alternative hypothesis is that boys are significantly smarter than girls.

boyscore=c(31,32,33,34,35,36,37,38,39,40)
girlscore=c(10,10,10,10,10,10,10,10,10,10)
ratioscore=boyscore/girlscore;
expratio=300/100;   #300 boy students and 100 girl students

chisq=sum((expratio-ratioscore)^2/expratio)
df=9
pvalue=1-pchisq(chisq,df)

Since the pvalue (0.9984578) is greater than significance level (0.05), we cannot
reject the null hypothesis. Therefore the conclusion is that boys are not significantly 
smarter than girls.
or we can say the conclusion is that score is not correlated with gender.

Am I right?

Thank you very much.

Van



More information about the R-help mailing list