Week 6

Kai Lukowiak

2017-10-28

Loading packages

library(dplyr)

Answer Questions:

6.6, 6.12, 6.20, 6.28, 6.44, 6.48

6.6 2010 Healthcare Law.

On June 28, 2012 the U.S. 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 Americans agree with this decision. At a 95% confidence level, 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.

(a) We are 95% confident that between 43% and 49% of Americans in this sample support the decision of the U.S. Supreme Court on the 2010 healthcare law.

False: because this is a sample, we are 100% sure that there are exactly (with rounding errors) 46% of respondents who support the decision.

We are 95% confident that between 43% and 49% of Americans support the decision of the U.S. Supreme Court on the 2010 healthcare law.

True: We are 95% sure that this is the case.

(c) If we considered many random samples of 1,012 Americans, and we calculated the sample proportions of those who support the decision of the U.S. Supreme Court, 95% of those sample proportions will be between 43% and 49%.

False: All we know is that there is a 95% chance that the sample contains the CI. The true value could be anything, say 44% which would mean repeated samples would actually center around 44, not 46.

(d) The margin of error at a 90% confidence level would be higher than 3%.

False: The MOE would be smaller because less confidence leads to higher ‘agreed ed’.

6.12 Legalization of marijuana, Part I.

The 2010 General Social Survey asked 1,259 US residents: “Do you think the use of marijuana should be made legal, or not?” 48% of the respondents said it should be made legal.

(a) Is 48% a sample statistic or a population parameter? Explain.

True: Yes, 48% is the sample statistic because that is the percent of the sample that agreed ed.

(c) A critic points out that this 95% confidence interval is only accurate if the statistic follows a normal distribution, or if the normal model is a good approximation. Is this true for these data? Explain.

\(\hat{p}\) is approximately normal when.

  1. The sample observations are independent; and
  2. There are at least 10 success and and failures.
success <- n * p
fail <- n * (p-1)

Since there are 604.32 successes and -654.68 failures and we can assume that they are independent, we can also assume that \(\hat{p}\) is a good estimator.

(d) A news piece on this survey’s findings states, “Majority of Americans think marijuana should be legalized.” Based on your confidence interval, is this news piece’s statement justified?

No, because most Americans in the study didn’t think it should be legal. However, it should also be noted that if we rephrased the hypothesis, it would be hard to reject the idea that most Americans thought it should be legal too.

6.20 Legalize Marijuana, Part II

As 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?

p <- 0.48
me <- 0.02
z <- qnorm(0.975)
vari <- (me / z)**2
n <- (p * (1-p)) / vari
n
## [1] 2397.07

The number of respondents would have to be 2398 people to achieve a 2% margin of error for a 95% confidence interval.

6.28 Sleep deprivation, 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 is 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 deprived and interpret it in context of the data.

pCal <- 0.08
pOr <- 0.088
nCal <- 11545
nOr <- 4691

SE <- sqrt((pCal * (1 - pCal)) / nCal + (pOr * (1 - pOr)) / nOr)
me <- qnorm(0.975) * SE
CI <- list((pOr - pCal) - me,(pOr - pCal) + me )

The 95% CI is between -0.001498 and 0.017498. This CI contains zero, so we cannot say they have different sleep patterns. Also, since the difference is small, even if n was large enough to be statistically significant, there may be little practical difference.

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 categorized as woods, 16 as cultivated grassplot, and 61 as deciduous forests. The table below summarizes these data.

(a) Write the hypotheses for testing if barking deer prefer to forage in certain habitats over others.

\(H_0:\) The sites with deer were the same as would be expected from the distribution of land.

\(H_a:\) The sites with deer were not the same as would be expected from the distribution of land.

(b) What type of test can we use to answer this research question?

We can use a \(\chi^2\) test.

(c) Check if the assumptions and conditions required for this test are satisfied.

  1. Independence
  • We can only assume this is the case.
  1. Sample Size and Distribution
  • Also satisfied.

(d) Do these data provide convincing evidence that barking deer prefer to forage in certain habitats over others? Conduct an appropriate hypothesis test to answer this research question.

library(dplyr)
library(tidyr)
cat <- c('Woods', 'Cultivated Grassplot', 'Deciduous Forests', 'Other')
num <- c(4, 16, 61, 345)
df <- as.data.frame(num)

RawSum <- sum(df$RawNumbers)
colnames(df) <- "RawNumbers"
df <- df %>% mutate(PercentDeer =  RawNumbers / colSums(df))
row.names(df) <- cat
df$percLand <- c(0.048, 0.147, 0.396,0.409)
df <- df %>% mutate(PredPerc = colSums(df)[1] * percLand)
k <- nrow(df)
degFree <- k - 1
num <- df %>% 
  mutate(chi2 = (PredPerc - RawNumbers)^2 / PredPerc) %>% 
  summarise(sumChi = sum(chi2))
num <- num[1,1]
pVal <- pchisq(num, degFree, lower.tail=FALSE)
pVal %>% round(,3)
## [1] 0

Since the p value is zero, we can reject the null that deer are indefferent on where they hang out.

6.48 Coffee 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 \(\leq\) 1 cup/wk 2-6 cups/wk 1 cup/day 2-3 cups/day \(\geq 4\) cups/day Total
Yes 670 373 905 564 95 2,607
No 11,545 6,244 16,329 11,726 2,288 48,132
Total 12,215 6,617 17,234 12,290 2,383 50,739

(a) What type of test is appropriate for evaluating if there is an association between coffee intake and depression?

The \(\chi^2\) for two way tables is appropriate to evlauate the association between coffee and depression.

(b) Write the hypotheses for the test you identified in part (a).

\(H_0:\) There is no association between coffee consumption and depression.

\(H_a:\) There is an an association between coffee consumption and depression.

(c) Calculate the overall proportion of women who do and do not suffer from depression.

dep <- 2607
noDep <- 48132
totDep <- dep + noDep
percDep <- noDep / totDep

The percentage of women who do not suffer from depression is: 94.86%

(d) Identify the expected count for the highlighted cell, and calculate the contribution of this cell to the test statistic, i.e.\((Observed−Expected)^2/Expected\)

k <- 5
degFree <- k - 1
expCount <- 340.1138
cell <- (373 - expCount)^2 / expCount

The contribution to the test statistic for the highlighted cell is 3.1798244.

(e) The test statistic is \(\chi^2 = 20.93\). What is the p-value?

The p-val is:

pVal <- pchisq(20.93, degFree, lower.tail=FALSE)
pVal
## [1] 0.0003269507

(f) What is the conclusion of the hypothesis test?

Because \(p \le p_{crit}\) we can reject the null and say that depression is related to the amount of coffee drunk.

(g) One of the authors of this study was quoted on the NYTimes as saying it was “too early to recommend that women load up on extra coffee” based on just this study. Do you agree with this statement? Explain your reasoning.

Yes, I agree with the statement, especially considereing there may be some selection bias in that happy women drink more coffee anyways.