5.6 Working backwards, Part II. A 90% confidence interval for a population mean is (65,77). The population distribution is approximately normal and the population standard deviation is unknown. This confidence interval is based on a simple random sample of 25 observations.Calculate the sample mean, the margin of error, and the sample standard deviation.

x2 <-77
x1 <-65
n=25

sample_mean<- (x2+x1)/2
sample_mean
## [1] 71
Margin_error<- (x2-x1)/2
Margin_error
## [1] 6
df <- n-1
p <- .9
p2 <- p+(1-p)/2
t_stat <-qt(p2, df)  
SE <- Margin_error/t_stat
SD <-SE*sqrt(n)
SD
## [1] 17.53481

5.12 Auto exhaust and lead exposure. Researchers interested in lead exposure due to car exhaust sampled the blood of 52 police officers subjected to constant inhalation of automobile exhaust fumes while working traffic enforcement in a primarily urban environment. The blood samples of these officers had an average lead concentration of 124.32 μg/l and a SD of 37.74 μg/l;a previous study of individuals from a nearby suburb, with no history of exposure, found an average blood level concentration of 35 μg/l.36

  1. Write down the hypotheses that would be appropriate for testing if the police officers appear to have been exposed to a higher concentration of lead.

Ho Mu=35 Ho: The average lead concentration in the blood samples for police officers is the same as the average lead concentration for people with no history of exposure to automobile exhaust fumes.

Ha Mu > 35 Ha: The average lead concentration in the blood samples for police officers is greater than the average lead concentration for people with no history of exposure to automobile exhaust fumes.

  1. Explicitly state and check all conditions necessary for inference on these data.

The problem statement does not provide details about how the samples (police officers blood) were collected. The entire population is unknown so you can not determine whether the sample population is less than 10%. We cannot determine whether the the samples observed are independent.

  1. Test the hypothesis that the downtown police officers have a higher lead exposure than the group in the previous study. Interpret your results in context.

Testing the t-stat, its clear to see that the t-score which measures the variation in the sample data is large so the greater the magnitude of the t-stat the greater the evidence to reject the null hypothesis.

tstat<- (124.32-35)/(37.74/sqrt(52))
tstat
## [1] 17.06666
  1. Based on your preceding result, without performing a calculation, would a 99% confidence interval for the average blood concentration level of police officers contain 35 μg/l?

No.The p-value is significantly smaller that the .005 level of significance.

5.18 Paired or not, Part II? In each of the following scenarios, determine if the data are paired.

  1. We would like to know if Intel’s stock and Southwest Airlines’ stock have similar rates of return. To find out, we take a random sample of 50 days, and record Intel’s and Southwest’s stock on those same days.

Paired

  1. We randomly sample 50 items from Target stores and note the price for each. Then we visit Walmart and collect the price for each of those same 50 items.

Paired

  1. A school board would like to determine whether there is a difference in average SAT scores for students at one high school versus another high school in the district. To check, they take a simple random sample of 100 students from each high school.

Not Paired

5.24 Sample size and pairing. Determine if the following statement is true or false, and if false, explain your reasoning: If comparing means of two groups with equal sample sizes, always use a paired test.

The statement is false, a paired test is only to be used when the variables are dependent.

5.30 Diamonds, Part II. In Exercise 5.28, we discussed diamond prices (standardized by weight) for diamonds with weights 0.99 carats and 1 carat. See the table for summary statistics, and then construct a 95% confidence interval for the average difference between the standardized prices of 0.99 and 1 carat diamonds. You may assume the conditions for inference are met.

myvec4 <- matrix(c(44.51, 56.81, 13.32, 16.13, 23, 23),byrow=TRUE, nrow=3)
colnames(myvec4) = c('.99 carats', '1 carat')
rownames(myvec4) = c('Mean','SD','n')
myvec4
##      .99 carats 1 carat
## Mean      44.51   56.81
## SD        13.32   16.13
## n         23.00   23.00
z<- 1.96
m99<- 44.51
sd99<- 13.32
n99<- 23
m1<- 56.81
sd1<- 16.13
n1<- 23

#CI_99 = avg +- z * se
error99<- qnorm(0.975)*sd99/sqrt(n99)
lower.bound<- m99 - error99
upper.bound<- m99+ error99
CI99<- c(lower.bound,upper.bound)
CI99
## [1] 39.06637 49.95363
error1<- qnorm(.975)*sd1/sqrt(n1)
lower.bound1<- m1 - error1
upper.bound1<- m1 + error1
CI1<- c(upper.bound1,lower.bound1)
CI1
## [1] 63.40202 50.21798

5.36 Gaming and distracted eating, Part II. The researchers from Exercise 5.35 also investigated the effects of being distracted by a game on how much people eat. The 22 patients in the treatment group who ate their lunch while playing solitaire were asked to do a serial-order recall of the food lunch items they ate. The average number of items recalled by the patients in this group was 4.9, with a standard deviation of 1.8. The average number of items recalled by the patients in the control group (no distraction) was 6.1, with a standard deviation of 1.8. Do these data provide strong evidence that the average number of food items recalled by the patients in the treatment and control groups are different?

Ho:Mu1=M2 Ha:Mu1!=Mu2

n<- 22
x1<- 4.9
x2<- 6.1
sd<- 1.8

t<- (x1-x2)/(1.8/sqrt(22))
t
## [1] -3.126944
alpha<- .05

SE<- qnorm(1-(alpha/2))
p<- 2*pnorm(t)
p
## [1] 0.001766337

p is lower than the .05 level of significance so we reject the null hypothesis in favor of the alternative.

5.42 Which test? We would like to test if students who are in the social sciences, natural sciences, arts and humanities, and other fields spend the same amount of time studying for this course. What type of test should we use? Explain your reasoning.

We should use a test of variance such as the anova test and partition by courses

5.48 Work hours and education. The General Social Survey collects data on demographics,education, and work, among many other characteristics of US residents.47 Using ANOVA, we can consider educational attainment levels for all 1,172 respondents at once. Below are the distributions of hours worked by educational attainment and relevant summary statistics that will be helpful in carrying out this analysis.

myvec4 <- matrix(c(38.67,3906,41.39,42.55,40.85,40.45,15.81,14.97,18.1,13.62,15.51,15.17,121,546,97,253,155,1172),byrow=TRUE, nrow=3)
colnames(myvec4) = c('Less than HS','HS','Jr Coll','Bachelors','Graduate','Total')
rownames(myvec4) = c('Mean','SD','n')
myvec4
##      Less than HS      HS Jr Coll Bachelors Graduate   Total
## Mean        38.67 3906.00   41.39     42.55    40.85   40.45
## SD          15.81   14.97   18.10     13.62    15.51   15.17
## n          121.00  546.00   97.00    253.00   155.00 1172.00
df<- myvec4[,-6]
boxplot(df,  boxwex = 0.25)

  1. Write hypotheses for evaluating whether the average number of hours worked varies across the five groups.

Ho: Mu1=Mu2=Mu3=Mu4=Mu5 Ha: Mu1:Mu5 are not equal

  1. Check conditions and describe any assumptions you must make to proceed with the test.

Based on the data, I will assume the data are independent.The box plots show extreme values so I would expect the data to be skewed and not normally distributed.

  1. Below is part of the output associated with this test. Fill in the empty cells. df + dfResidual
PrF<- 0.0682
k<- 5
n1<- c(121,546,97,253,155)
n<- sum(n1)-k
dfG<- k-1
dfE<- n-k
dfT<- dfG+dfE
df<- c(dfG, dfE, dfT)
df
## [1]    4 1162 1166
SSE<- 267382
MSG<- 501.54
MSE<- SSE/dfE
MS<- c(MSG, MSE, NA)
MSE
## [1] 230.105
FV<- MSG/MSE
FV
## [1] 2.179614
anova.dt <- data.frame(df, SSE, MSG, c(FV, NA, NA), c(PrF, NA, NA))
colnames(anova.dt) <- c("Df", "Sum Sq", "Mean Sq", "F Value", "Pr(>F)")
rownames(anova.dt) <- c("degree", "Residuals", "Total")
anova.dt [1:5]
##             Df Sum Sq Mean Sq  F Value Pr(>F)
## degree       4 267382  501.54 2.179614 0.0682
## Residuals 1162 267382  501.54       NA     NA
## Total     1166 267382  501.54       NA     NA

6.8 Elderly drivers. In January 2011, The Marist Poll published a report stating that 66% of adults nationally think licensed drivers should be required to retake their road test once they reach 65 years of age. It was also reported that interviews were conducted on 1,018 American adults, and that the margin of error was 3% using a 95% confidence level.41

  1. Verify the margin of error reported by The Marist Poll.
ME<- qnorm(.975)*(sqrt(.66*.44/1018))
ME
## [1] 0.03310339
  1. Based on a 95% confidence interval, does the poll provide convincing evidence that more than 70% of the population think that licensed drivers should be required to retake their road test once they turn 65?
phat<- .66
pnot<- .7
n<- 1018

z=(phat-pnot)/sqrt(pnot*(1-pnot)/n)
z
## [1] -2.784994
SE<- sqrt(phat*(1-phat)/n)
CI.upper<- phat+z*SE
CI.lower<- phat-z*SE
CI<-c(CI.lower,CI.upper)
CI
## [1] 0.7013487 0.6186513
alpha<- .05
pval<- pnorm(z,lower.tail = FALSE)
pval
## [1] 0.9973236

With the p-value (0.9973236) much greater than the .05 level of significance we fail to reject the null hypothesis and conclude that the data do not provide convincing evidence that more than 70% of the population think that licensed drivers should be required to retake their road test. This is also evident in the p-value which is outside of the confidence interval (0.7013487 , 0.6186513)

6.16 Is college worth it? Part I. Among a simple random sample of 331 American adults who do not have a four-year college degree and are not currently enrolled in school, 48% said they decided not to go to college because they could not afford school.49

  1. A newspaper article states that only a minority of the Americans who decide not to go to college do so because they cannot afford it and uses the point estimate from this survey as evidence. Conduct a hypothesis test to determine if these data provide strong evidence supporting this statement.

Ho:Mu1=Mu2 <50% of American adults who decide not to go to college do so b/c they cannot afford it

Ha:Mu1!=Mu2 ’>50% of American adults who decide not to go college do so b/c they cannot afford it

phat<- .48
pnot<- .50
n=331

z<-(phat-pnot)/sqrt(pnot*(1-pnot)/n)
z
## [1] -0.7277362
z.alpha<- pnorm(z, lower.tail = FALSE)
z.alpha
## [1] 0.7666125
pval<- pnorm(z,lower.tail = FALSE)
pval
## [1] 0.7666125

The p-value is very high so we fail to reject the null hypothesis and conclude that the data do not provide sufficient evidence to support the newspapers statement.

  1. Would you expect a confidence interval for the proportion of American adults who decide not to go to college because they cannot afford it to include 0.5? Explain.
phat<-.48
n<-331
SE<-sqrt(phat*(1-phat)/n) 
SE
## [1] 0.02746049
CI.upper1<-(phat+1.96)*SE
CI.lower1<-(phat-1.96)*SE
CI1<- c(CI.upper1,CI.lower1)
CI1
## [1]  0.06700360 -0.04064153

Since the the variability is .027 and the point estimate is .48, I would expect that the 95% confidence interval would contain our point estimate.

6.24 Heart transplant success. The Stanford University Heart Transplant Study was conducted to determine whether an experimental heart transplant program increased lifespan. Each patient entering the program was officially designated a heart transplant candidate, meaning that he was gravely ill and might benefit from a new heart. Patients were randomly assigned into treatment and control groups.Patients in the treatment group received a transplant, and those in the control group did not. The table below displays how many patients survived and died in each group.

myvec1 <- matrix(c(4,24,30,25),byrow=TRUE, nrow=2)
colnames(myvec1) = c('control','treatment')
rownames(myvec1) = c('alive','dead')
myvec1
##       control treatment
## alive       4        24
## dead       30        25

A hypothesis test would reject the conclusion that the survival rate is the same in each group,and so we might like to calculate a confidence interval. Explain why we cannot construct such an interval using the normal approximation. What might go wrong if we constructed the confidence interval despite this problem?

We cannot construct a confidence interval because we are unable to verify the independence of the variables provided. We do not know if the samples are less than 10% of the population and whether they were chosen through random samples. The data are counts and less so observations from real time experiments. This data is tabular and stale and more conducive to a goodness of fit test, such as the chi square test.

6.32 Full body scan, Part I. A news article reports that “Americans have differing views on two potentially inconvenient and invasive practices that airports could implement to uncover potential terrorist attacks.” This news piece was based on a survey conducted among a random sample of 1,137 adults nationwide, interviewed by telephone November 7-10, 2010, where one of the questions on the survey was “Some airports are now using ‘full-body’ digital x-ray machines to electronically screen passengers in airport security lines. Do you think these new x-ray machines should or should not be used at airports?” Below is a summary of responses based on party affiliation.

myvec5 <- matrix(c(264,299,38,55,16,15),byrow=TRUE, nrow=3)
colnames(myvec5) = c('Republican','Democrat')
rownames(myvec5) = c('Should','Should not','Dont Know/No answer')
myvec5
##                     Republican Democrat
## Should                     264      299
## Should not                  38       55
## Dont Know/No answer         16       15
  1. Conduct an appropriate hypothesis test evaluating whether there is a difference in the proportion of Republicans and Democrats who think the full-body scans should be applied in airports. Assume that all relevant conditions are met.

Ho: Mu1=Mu2 There is no difference in the proportion of republicans and democrats who think think the full-body scans should be applied in airports

Ha: Mu1!=Mu2

There is a difference in the proportion of republicans and democrats who think think the full-body scans should be applied in airports

chisq.test(myvec5)
## 
##  Pearson's Chi-squared test
## 
## data:  myvec5
## X-squared = 1.5381, df = 2, p-value = 0.4635

The p-value is greater than .05 so we fail to reject the null hypothesis and conclude that there is no difference in proportion of republicans and democrats who think think the full-body scans should be applied in airports.

  1. The conclusion of the test in part (a) may be incorrect, meaning a testing error was made. If an error was made, was it a Type 1 or a Type 2 Error? Explain.

Type 2 error, because we failed to reject the null when the null is actually false

6.40 True or false, Part II. Determine if the statements below are true or false. For each false statement, suggest an alternative wording to make it a true statement.

  1. As the degrees of freedom increases, the mean of the chi-square distribution increases.

True

  1. If you found #2 = 10 with df = 5 you would fail to reject H0 at the 5% significance level.

True

.08 > .05

So we fail to reject the null hypothesis

chi<- pchisq(10,5,lower.tail = F)
chi
## [1] 0.07523525
  1. When finding the p-value of a chi-square test, we always shade the tail areas in both tails.

False. The Chi square one sided test can be used to measure the difference between groups in a specific direction while the two sided test uses both the positive and negative tails of the distribution.

  1. As the degrees of freedom increases, the variability of the chi-square distribution decreases.

True

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.

  1. What type of test is appropriate for evaluating if there is an association between coffee intake and depression?

You can test for the independence between the variables in this tabular data frame using a chi square test

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

Ho: Mu1=Mu2 There is no relationship between depression and coffee intake

Ha: Mu1 != Mu2 There is a relationship between depression and coffee intake

  1. Calculate the overall proportion of women who do and do not suffer from depression.
a<- .05
pop<-50739
DNS<- a*pop
DNS
## [1] 2536.95
DS<- pop-DNS
DS
## [1] 48202.05
  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.
a<- .05
pop<-50739
DNS<- a*pop
Tot<- 6617
obs<-373
exp<- (DNS*Tot/pop)
exp
## [1] 330.85
Independence<- (obs-exp)^2/exp
Independence
## [1] 5.369873
  1. The test statistic is #2 = 20.93. What is the p-value?
tstat<- 20.93
df<- 4
pval<- 1-pchisq(tstat,df)
pval
## [1] 0.0003269507
  1. What is the conclusion of the hypothesis test?

The p-value is below the .05 level of significance so we reject the null hypothesis that there is no relationship between depression and coffee intake.

  1. 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. There may be a confounding variable that could explain the cause and effect relationship.

6.56 Is yawning contagious? An experiment conducted by the MythBusters, a science entertainment TV program on the Discovery Channel, tested if a person can be subconsciously influenced into yawning if another person near them yawns. 50 people were randomly assigned to two groups: 34 to a group where a person near them yawned (treatment) and 16 to a group where there wasn’t a person yawning near them (control). The following table shows the results of this experiment

myvec4 <- matrix(c(10,4,24,12),byrow=TRUE, nrow=2)
colnames(myvec4) = c('Treatment','Control')
rownames(myvec4) = c('Yawn','Not Yawn')
myvec4
##          Treatment Control
## Yawn            10       4
## Not Yawn        24      12

A simulation was conducted to understand the distribution of the test statistic under the assumption of independence: having someone yawn near another person has no influence on if the other person will yawn. In order to conduct the simulation, a researcher wrote yawn on 14 index cards and not yawn on 36 index cards to indicate whether or not a person yawned. Then he shuffled the cards and dealt them into two groups of size 34 and 16 for treatment and control, respectively.He counted how many participants in each simulated group yawned in an apparent response to a nearby yawning person, and calculated the difference between the simulated proportions of yawning as ˆptrtmt,sim − ˆpctrl,sim. This simulation was repeated 10,000 times using software to obtain 10,000 differences that are due to chance alone. The histogram shows the distribution of the simulated differences.

  1. What are the hypotheses for testing if yawning is contagious, i.e. whether it is more likely for someone to yawn if they see someone else yawning?

Ho: Having someone yawn near another person has no influence on if the other person will yawn

Ha: having someone yawn near another person has an influence on if the other person will yawn

  1. Calculate the observed difference between the yawning rates under the two scenarios.
Control<- 4/16
Control
## [1] 0.25
Treatment<- 10/34
Treatment
## [1] 0.2941176
  1. Estimate the p-value using the figure above and determine the conclusion of the hypothesis test.
pval<- chisq.test(myvec4)
## Warning in chisq.test(myvec4): Chi-squared approximation may be incorrect
pval
## 
##  Pearson's Chi-squared test with Yates' continuity correction
## 
## data:  myvec4
## X-squared = 0, df = 1, p-value = 1

The p-value is one indicating a perfect relationship between the two variables and with the high value we fail to reject the null in favor of the alternative that seeing someone yawn has an influence on the other person yawning