This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Math 127B, Basic R, Lecture 6 Mrinal Raghupathi Wednesday, April 20, 2011 Administrivia Today we will learn how to do a chi-square test in R. Reminders 1. This weeks recitation will again be like a lab for R, in-class. 1 The chi-square test in R The chi-square test is run with the command chisq.test . The command can do all the chi-square 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  11 13 15 10 9 2 > chisq.test(rolls) Chi -squared test for given probabilities data: rolls X-squared = 10, df = 5, p-value = 0.07524 Note the P-value is given as a proportion and not as a percentage. So P = 7 . 524%. Next lets work out the example of the jurors in Alameda county California. Heres the table again. 1 Age County-wide % age Number 21 30 42 5 31 40 23 9 41 60 16 19 61 + 19 33 This time, there is a lot less information. We dont need it. TheThis time, there is a lot less information....
View Full Document