6.6 2010 Healthcare Law. On June 28th, 2012 the US Supreme Court upheld the much debated 2010 healthcare law, declaring it constitutional. A Gallup poll released the day after this decision indicates that 46% of 1,012 American agree witht his decision. At a 95% confidence interval, this sample has a 3% margin of error. Based on this information, determine if the following statements are true or false and explain your reasoning.

+This statement is true based on the definition of confidence interval 46-3, 46+3 (43, 49).

6.20 Legalization of marijuana, Part II. As we discussed in Exercise 6.12, the 2010 General Social Survey reported a sample where about 48% of US residents thought marijuana should be made legal. If we wanted to limit the margin of error of a 95% confidence interval to 2% about how many Americans would we need to survey?
6.28 Sleep depreivation, CA vs. OR, Part I. According to a report on sleep deprivation by the Centers for Disease Control and Prevention, the proportion of California residents who reported insufficient rest or sleep during each of the preceding 30 days in 8.0% while this proportion is 8.8% for Oregon residents. These data are based on simple random samples of 11,545 California and 4,691 Oregon residents. Calculate a 95% confidence interval for the difference between the proportions of Californians and Oregonians who are sleep depreived and interpret it in context of the data.
zstar <- 1.96
n.cali <- 11545
n.oregon <- 4691
mean.cali <- .08
mean.oregon <- .088
meandiff <- mean.cali - mean.oregon
SE <- sqrt((((mean.cali)*(1-mean.cali)/n.cali)+mean.oregon)*(1-mean.oregon)/(n.oregon))

CIUPPER <- meandiff+(zstar*SE)
CILOWER <- meandiff-(zstar*SE)
CI.28 <- c(CILOWER, CIUPPER)
CI.28
## [1] -0.0161073298  0.0001073298
##our CI is (-.0161, 0001). Since our CI includes 0, we can say that there no significance data supporting that there is a difference in the sleep deprivation of Californians and Oregonians.
6.44 Barking deer. Microhabitat factors associated with forage and bed sites of barking deer in Hainan Island, China were examined from 2001 to 2002. In this region woods make up 4.8% of the land, cultivated grass plot makes up 14.7%, and deciduous forests makes up 39.6%. Of the 426 sites where the deer forage, 4 were catergorized as woods, 16 as cultivated grassplot, as 61 as deciduous forests. The table below summarizes these data.
#see attachment for calculations

chisquare <- pchisq(284.067, 3, lower.tail =FALSE)
chisquare
## [1] 2.791297e-61
#our chi-square pvalue is 2.791297e-61 or 0 so we can conclude that the data does not support that barking deer forage in certain areas over others.
6.48 Coffe and Depression. Researchers conducted a study investigating the relationship between caffeinated coffee consumption and risk of depression in women. They collected data on 50,739 women free of depression symptoms at the start of the study in the year 1996 and these women were followed through 2006. The researchers used questionnaires to collect data on caffeinated coffee consumption, asked each individual about physician-diagnosed depression, and also asked about the use of antidepressants. The table below shows the distribution of incidences of depression by amount of caffeinated coffee consumption.
depression <- 2607
no.depression <- 48132
total <- depression + no.depression
prop.depression <- depression/total
prop.nodepression <- no.depression/total
prop.depression
## [1] 0.05138059
prop.nodepression
## [1] 0.9486194
#.05 have depression and  .95 do not
#using the proportions from above
expected <- prop.depression*6617
expected
## [1] 339.9854
observed <- 373
statistic <- ((observed-expected)^2)/expected
statistic
## [1] 3.205914
#contribution of this cell is 3.21

*The test statistic is chi-squared = 20.93. What is the pvalue?

pvalue <- pchisq(20.93, 4)
pvalue <- 1-pvalue
pvalue
## [1] 0.0003269507
#our pvalue is .0003 

*What is the conclusion of the hypothesis test?

+ Because our pvalue is less than .05, we can conclude that there is not enough data supporting the association between caffinated coffee consumption and depression ie fail to reject the null hypothesis.