start of class question....
we want to see if whether parents allowing their children to drink around them makes any difference on whether or not the student binge drinks. Students were asked whether they could drink around their parents and then how many drinks they typically had in a session of drinking. Below are the two sets of data.
Do your thing:
allow.to.drink=c(2.5, 7, 3.5, 6, 5, 1, 7, 2, 5, 1, 2.5, 6.5, 1, 2.5, 5, 3, 4, 5, 3, 3, 1, 8, 3, 4.5, 10, 3, 6, 3, 9, 7, 3, 6, 6, 5, 4, 3, 3, 4, 4, 4, 2.5, 6, 2, 4, 4, 2.5, 3, 7, 3, 4, 3.5, 4, 5, 4, 2, 5, 8, 7, 6, 2.5, 2, 5, 1, 4, 2.5)
no.drink=c(9, 8, 4, 3.5, 4, 3, 3, 4, 1, 5, 5, 1, 7, 1, 7, 3, 3.5, 4, 3, 4, 10, 3, 4, 6, 9, 5, 2, 3, 7)
1. Let's look at this table:
binge = "five or more drinks in a row three times in the past two weeks"
* get this table into r. call it drinkers or something else that clever. make sure as a final step you turn it into a table. make sure it's not still a matrix.
compare:
margin.table(drinkers)
margin.table(drinkers,1)
margin.table(drinkers,2)
compare:
prop.table(drinkers)
prop.table(drinkers,1)
prop.table(drinkers,2)
prop.table(margin.table(drinkers,1))
expected values:
((row total )*(column total))/n
let's do this by hand for our data.
(for those interested in how it looks in r.... http://www.cyclismo.org/tutorial/R/tables.html . I have yet to find an easier way )
chi-squared test:
p. 568 of your book. it works just like all of our other tests....
compare the difference of what we HAVE to what we would EXPECT and determine if that's enough for us to say the differences are significant.
you can do it to your data simply by:
summary(drinkers)
from page 570: ...all cell counts should be above 1, and 80% have a count higher than 5. (I paraphrased a little bit.)
Data Set 2:
ya.live <- matrix(c(324,378,337,318,37,47,40,38,116,279,372,487,58,60,49,25,5,2,3,9), ncol=4, byrow=TRUE)
colnames(ya.live)=c("19","20","21","22")
rownames(ya.live)=c("Parents House","Another Persons Home","Own Place","Group Quarters","Other")
ya.live.t=as.table(ya.live)
...
barplot(ya.live)
...
Data Set 3:
look below for our sleep_face data...import like a regular .csv
summary(sleep_face)
table(sleep_face)
Data Set 4:
A study of people who refused to answer survey questions is shown below:
let's get this table into r, but in a slightly different way....
responses = matrix(nrow=2, ncol=6, byrow=TRUE)
data.entry(responses) #here you will input your numbers and column names
rownames(responses) <-c("Responded", "Refused")
colnames(responses) <-c("18-21","22-29","30-39","40-49","50-60","60+")
response.table = as.table(responses)
response.table