MSDS Spring 2018

DATA 606 Statistics and Probability for Data Analytics

Jiadi Li

Chapter 6: Inference for Categorical Data

HW 6: 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.

Margin of error = 3%
95% confidence level
46% of 1,012 agreed

(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: we are exactly 46% of Americans in this sample agree with the decision.

  1. 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: based on the definition of an 95% confidence interval.

  2. 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: the 43% to 49% confidence interval is based on this group of sample. The interval gives a range of value in which the whole population whould be located with a 95% confidence level.

  3. The margin of error at a 90% confidence level would be higher than 3%.
    False: the margin of error would be less than 3% since we are less confident about the result.

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.

sample: 1,259
48% said should be legal

(a) Is 48% a sample statistic or a population parameter? Explain.
Sample parameter: since the number is calculated based on the sample of resndents.

  1. Construct a 95% confidence interval for the proportion of US residents who think marijuana should be made legal, and interpret it in the context of the data.
n <- 1259
p <- 0.48
se <- ((p * (1 - p)) / n) ^ 0.5
me <- 1.96 * se #parameter for 95% confidence level
confidence_interval <- c(p - me, p + me)

confidence_interval
## [1] 0.4524028 0.5075972
  1. 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.
    This is true for these data: the data is a sample of Americans; the sample size is large enough; and the sample observations are independent.

  2. 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?
    As majority should be over 50%, and the confidence interval crossed both sides of 50%, we can’t reject either hypothesis.

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

se_n <- 0.02/qnorm(0.95 + (1 - 0.95)/2)
n <- (((p * (1 - p)) ^ 0.5) / se_n)^2

n
## [1] 2397.07
se <- ((p * (1 - p)) / n) ^ 0.5
me <- 1.96 * se #parameter for 95% confidence level
confidence_interval <- c(p - me, p + me)

me #should be approximately 2%
## [1] 0.02000037
confidence_interval
## [1] 0.4599996 0.5000004

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.

p_CA <- 0.08
n_CA <- 11545
p_OR <- 0.088
n_OR <- 4691

z <- qnorm(0.95 + (1 - 0.95)/2)
se <- ((p_CA * (1 - p_CA) / n_CA) + (p_OR * (1 - p_OR) / n_OR))^0.5

confidence_interval <- c((p_CA - p_OR) - z*se, (p_CA - p_OR) + z*se)
confidence_interval
## [1] -0.017497954  0.001497954

0 is within the confidence interval meaning that both population should be equal.

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.

  1. Write the hypotheses for testing if barking deer prefer to forage in certain habitats over others.
total <- 426
wood <- total * 0.048
cultivated_grass_plot <- total * 0.147
deciducous_forest <- total * 0.396

\(H_0\): All sites across the habitat is distributed as above.
\(H_A\): Not all of the sites aross the habitats is distributed based on the table above.

  1. What type of test can we use to answer this research question?
    Chi-square test.

  2. Check if the assumptions and conditions required for this test are satisfied.
    Independence: assumed.
    Sample size: satisfied.

  3. 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.

sites <- c(4,16,67,345)
habitat <- c(wood,cultivated_grass_plot,deciducous_forest,(total-wood-cultivated_grass_plot-deciducous_forest))

chi_square <- sum((sites - habitat)^2/habitat)

1 - pchisq(chi_square,df=3)
## [1] 0

6.48 Coffee and Depression.

Researchers conducted a study investigating the relationship between ca???einated 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 caffieinated co???ee 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.

  1. What type of test is appropriate for evaluating if there is an association between coffee intake and depression?
    Association between coffee intake and depression \(\Rightarrow\) Chi-square test with two way tables.

  2. Write the hypotheses for the test you identified in part (a).
    \(H_0\): No association.
    \(H_A\): Association between coffee intake and depression.

  3. Calculate the overall proportion of women who do and do not suffer from depression.

depression <- 2607
no_depression <- 48132

depression/(depression + no_depression)
## [1] 0.05138059
no_depression/(depression+no_depression)
## [1] 0.9486194
  1. 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\).
two_SixCups <- 6617
Observed <- 373
(Observed - two_SixCups)^2/two_SixCups
## [1] 5892.026
  1. The test statistic is \(X^2\) = 20.93. What is the p-value?
1 - pchisq(20.93,(5-1)*(2-1))
## [1] 0.0003269507
  1. What is the conclusion of the hypothesis test?
    \(\because\) 0.0003269507 < 0.05, \(\therefore\) reject \(H_0\).

  2. 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.
    Agreed, since there is no clear association between coffee intake and depression.