Graded: 6.6, 6.12, 6.20, 6.28, 6.44, 6.48
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 : We know 46% of Americans in this sample support the health care law. Therefore we are 100% confident. The confidence interval applies to the entire population and not just to the sample taken.
phat <- .46
n <- 1012
alpha <- 0.05
ME<- .3
Z <- qnorm(alpha, lower.tail = FALSE)
SE <- sqrt(
phat*(1-phat) /n
)
SE
## [1] 0.01566699
MarginOfErro <- Z*SE
MarginOfErro
## [1] 0.0257699
phat+MarginOfErro
## [1] 0.4857699
phat-MarginOfErro
## [1] 0.4342301
True. That’s what the confidence interval tells us ***
FALSE: Here question is reffering to Sample propotion, but % derived is from Confidence Interval. Our confidence interval gives us a range of possible values for the true population proportions not the sample Propotions.
phat <- .46
n <- 1012
alpha <- 0.05
ME<- .3
Z <- qnorm(alpha, lower.tail = FALSE)
SE <- sqrt(
phat*(1-phat) /n
)
SE
## [1] 0.01566699
MarginOfErro <- Z*SE
MarginOfErro
## [1] 0.0257699
phat+MarginOfErro
## [1] 0.4857699
phat-MarginOfErro
## [1] 0.4342301
alpha <- 1-.90
Z <- qnorm(alpha, lower.tail = FALSE)
SE <- sqrt(
phat*(1-phat) /n
)
SE
## [1] 0.01566699
MarginOfErro90 <- Z*SE
MarginOfErro90
## [1] 0.02007805
MarginOfErro
## [1] 0.0257699
phat+MarginOfErro90
## [1] 0.4800781
phat-MarginOfErro90
## [1] 0.4399219
at 95% ME : 0.0257699 with CI : c(0.4342301, 0.4857699 ), at 90% MarginOfErro 0.0200781, with CI : c(0.4399219, 0.4800781 )
The CI will be narrower and the so the margin of error will be smaller.
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 di???erence between the proportions of Californians and Oregonians who are sleep deprived and interpret it in context of the data.53
Claim nH : No difference in sleep deprivation i.e. Pcal = POre aH : Difference in sleep deprivation i.e. Pcal Not = POre
Dif of two propotion phat <- p1-p2 SE <- sqrt((p1(1-p1)/n1) + (p2(1-p2)/n2) ) ME <- Zalpha * SE
CI (point estimate + - ME)
point estimate = P1- p2
nCal<- 11545
phatsleepCal <- .08
nOre<- 4691
phatsleepOre <- .088
aplha <- .05 # for 95% cof interval
phatdiff <- phatsleepCal - phatsleepOre
phatdiff
## [1] -0.008
# Compute standard error and margin of error for the proportion difference.
Z <- qnorm(alpha/2, lower.tail = FALSE) #1.96 #
SEDiff <- sqrt((phatsleepCal*(1-phatsleepCal)/nCal) + (phatsleepOre*(1-phatsleepOre)/nOre) )
MarginOfErro <- Z*SEDiff
MarginOfErro
## [1] 0.009497954
HI =phatdiff+MarginOfErro
# HI
LI =phatdiff-MarginOfErro
# LI
c(LI,HI)
## [1] -0.017497954 0.001497954
# -----Calcualte Z test statics so we can find pvalue
# Also since its two categorical vlaue we need to get ppool ie. phatpool <- (p1+p2)/(np1+np2)
phatpool <- (phatsleepCal+phatsleepOre)/(nCal+nOre)
phatpool
## [1] 1.034738e-05
Ztest <- (phatdiff-0)/sqrt(((phatpool*(1-phatpool))/nCal) +
((phatpool*(1-phatpool))/nOre))
Ztest
## [1] -143.6373
pvalueProp <- 1 - pnorm(Ztest)
pvalueProp <= alpha # Reject
## [1] FALSE
pvalueProp > alpha # Failed to Reject
## [1] TRUE
We fail to reject Null hypothessis as Pvalue is greater than Alpha . ***
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.62 Woods Cultivated grassplot Deciduous forests Other Total 4 16 67 345 426
H0: The barking deer does not prefer a certain habitat to forage. HA: The barking deer has certain habitats that it prefer to forage.
We can use a chi-squared test to answer this research question. Since we have cases that can be classified into several groups (deer habitats where they forage), we can determine if the forage habitats proportion is representative of the land make up.
Independence: We will have to assume it since is not given in the description.
Sample size / distribution: In our expected cases scenario, all habitats have at least 5 expected cases, therefore this condition is satisfied since it has at least 5 expected cases.
habitats <- c(4, 16, 67, 345)
region <- c(20.45, 62.62, 168.70, 174.23)
k <- length(habitats)
df <- k - 1
# Compute the chi2 test statistic
chi <- (habitats - region ) ^ 2 / region
chi <- sum(chi)
# check the chi2 test statistic and find p-val
p_Val <- 1 - pchisq(chi, df = df)
The chi-Square value is large enough that the p-value is 0. Hence, we conclude that there is convincing evidence the barking deer forage in certain habitats over others.
between ca???einated co???ee 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 ca???einated 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 ca???einated co???ee consumption.63 Ca???einated co???ee consumption ???1 2-6 1 2-3 $ 4 cup/week cups/week cup/day cups/day cups/day Total Clinical Yes 670 373 905 564 95 2,607 depression 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 co???ee intake and depression?
The Chi-squared test for two-way tables is appropriate for evaluating if there is an association between coffee intake and depression.
The hypotheses for the Chi-squared two-way table test are as follows.
H0: There is no association between caffeinated coffee consumption and depression.
HA: There is an association between caffeinated coffee consumption and depression.
yes_dep <- 2607
no_dep <- 48132
total_dep <- yes_dep + no_dep
total_dep
## [1] 50739
p_depressed = (2607/total_dep) * 100;
round(p_depressed, digits=2) #women who are depressed
## [1] 5.14
p_normal = (48132/total_dep) * 100;
round(p_normal, digits=2) #women who are normal
## [1] 94.86
The overall proportion of women who do suffer from depression is 5.14%. The overall proportion of women who do not suffer from depression is 94.86%
groups = 5
dF = 4
expected = ((2607/50739 )*6617)
Observed <- 373
chipart = (Observed - expected)^2/expected
chipart
## [1] 3.205914
The expected count for the highlighted value is 3.2059144
n <- 5
k <- 2
df <- (n-1)*(k-1)
chi2 <- 20.93
pValue = pchisq(chi2,dF,lower.tail = FALSE)
pValue
## [1] 0.0003269507
The p-value is 0.0003269507
Since the p-value is very small (0.0003), since its smaller than the 0.05 we reject the null hypothesis that There is no association between caffeinated coffee consumption and depression.
I agree it is too early to recommend that women load up on extra coffee. Based on this study, there is a very weak relationship between coffee consumption and depression among women. further tests would need to be conducted a before we can explicitly state that coffee effectively treats depression in women.