6.6 2010 Healthcare Law.

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

Answer: FALSE -A confidence interval estimateS the population proportion, not the sample proportion.
(b) 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.

Answer: TRUE - A confidence interval estimates the population proportion = 46% plus or minus 3% = (43%-49%)
(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%.```

Answer: TRUE - This is the confidence interval
(d) The margin of error at a 90% confidence level would be higher than 3%.

Answer: FALSE - At 90% Ci the Margin of Error will be less than 3% and the CI will be narrower, since 90% is less than 95%.

6.12 Legalization of marijuana, Part I.

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

Answer: This is a sample statistic derived from a sample of 1259 residents.
(b) 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 <- sqrt((p * (1-p))/n)
( ME <- 1.96 * SE )
## [1] 0.02759723
Answer: The confidence interval is 0.46 plus or minus 0.0275 = (0.4524028 , 0.5075972). This means we are 95% confident that proportion US residents how want to legalize marijuana is between 45.2% and 50.76%.
(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.

Answer:  Yes, this is true for this data. If the sample is independent and the size of the sample is large enough such that if n* p >= 10 and n*(1-p) >= 10 p will be normally distributed. p and one_minus_p below are both greater than 10
p <- 0.48 * 1259
one_minus_p <- 0.52 * 1259
p
## [1] 604.32
one_minus_p
## [1] 654.68
(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, the statement is not justified. We can reject the hypothesis that the proportion of Americans who think marijuana should be legalized is above 50% and nor can we reject the hypothesis that its lower than 50%.

6.20 Legalize Marijuana, Part II.

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

# ME = 1.96 * SE
SE <- ME / 1.96

# SE = sqrt((p * (1-p)) / n) 
# SE^2 = (p * (1-p)) / n
( n <- (p * (1-p)) / (SE^2) )
## [1] 2397.158

``` Thus we need approximately 2,397 survey respondents.

6.28 Sleep deprivation, CA vs. OR, Part I.

  1. The sample was selected simple random process and it repsents less than 10% of the population. We have at least 10 successes and failures for both states, so the distribution can be approximated using the normal model.
p_ca <- 0.08
p_or <- 0.088

p <- p_ca - p_or
p
## [1] -0.008
n_ca <- 11545
n_or <- 4691

SE2_ca <- (p_ca * (1-p_ca)) / n_ca
SE2_or <- (p_or * (1-p_or)) / n_or

SE <- sqrt(SE2_ca + SE2_or)
ME <- 1.96 * SE 
ME
## [1] 0.009498128
The confidence interval is (-0.0174981, 0.0014981), therefore we are 95% confident that that the difference between the proportion of CA residents and OR residents who are sleep deprived falls between (-0.0174981, 0.0014981).

6.44 Barking deer.

  1. 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.
observed <- c(4, 16, 61, 345, 426)
expected_prop <- c(0.048, 0.147, 0.396, 1-0.048-0.147-0.396, 1)
expected <- expected_prop * 426
deer <- rbind(observed, expected)
colnames(deer) <- c("woods", "grassplot", "forests", "other", "total")
deer
##           woods grassplot forests   other total
## observed  4.000    16.000  61.000 345.000   426
## expected 20.448    62.622 168.696 174.234   426
(a) HO: BDeer_Preference_to_Forage_Certain_Habitat = 0 
    HA: BDeer_Preference_to_Forage_Certain_Habitat != 0
(b) One can use the Chi-square goodness of fit test.
(c) Independence and Sample Size / distribution must be validated before performing a Chi-Squared test.
 
    Assuming the barking dear habitats variables are independent. Then each habitat cell count must be a least 5 cases. The woods habitat only has 4.8 so it is just shy of the target 5, but may still be acceptable.
(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.

HO: BDeer_Preference_to_Forage_Certain_Habitat = 0 
HA: BDeer_Preference_to_Forage_Certain_Habitat != 0
k <- 4
df <- k-1

chi2 <- sum(((deer[1,] - deer[2,])^2)/deer[2,])
( p_value <- 1 - pchisq(chi2, df) )
## [1] 0
Given a p-value of near 0, we would reject the Null hypothesis. Barking deer do have a preference for foraging in certain habitats.

6.48 Coffee and Depression.

(a) Chi-squared test for 2-way tables
(b)  H0: There is no association between caffeine consumption and depression
     HA: There is an association between caffeine consumption and depression
     
(c)
wdep<- (2607/50739)
wodep<- (48132/50739)
wdep*100 
## [1] 5.138059
wodep*100
## [1] 94.86194
(d) 
exp <- wdep*6617
cellcont <- ((373 - exp)^2)/exp
cellcont
## [1] 3.205914
(e)
k <- 5
df <- (k-1)
pvalue <- pchisq(20.93,df, lower.tail = FALSE)
pvalue
## [1] 0.0003269507