Math 127B, Basic R, Lecture 6
Mrinal Raghupathi
Wednesday, April 20, 2011
Administrivia
Today we will learn how to do a chisquare test in R.
Reminders
1. This week’s recitation will again be like a lab for R, inclass.
1
The chisquare test in R
The chisquare test is run with the command
chisq.test
. The command can do all the chisquare
tests that we have looked at. This can be done by specifying different options.
We will repeat three of the examples from previous classes. The first is rolls of a die. We roll a
die 60 times and observe the following frequencies for each face: 11, 13, 15, 10, 9, 2. Create a list
of frequencies for the rolls by
rolls < c(11, 13, 15, 10, 9, 2)
.
The command
chisq.test(rolls)
will print out the following information
>
rolls
<
c(11,
13,
15,
10,
9,
2)
>
rolls
[1]
11
13
15
10
9
2
>
chisq.test(rolls)
Chi squared
test
for
given
probabilities
data:
rolls
Xsquared
=
10,
df
=
5,
pvalue
=
0.07524
Note the
P
value is given as a proportion and not as a percentage. So
P
= 7
.
524%.
Next let’s work out the example of the jurors in Alameda county California. Here’s the table
again.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '11
 Staff
 Statistics, ChiSquare Test, Chisquare distribution, Pearson's chisquare test

Click to edit the document details