Working backwards, Part II. (5.24, p. 203) 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.

Sample mean

(65+77)/2
## [1] 71

Margin of error

ME<-(77-65)/2
ME
## [1] 6

sample standard deviation

t<-qt(0.95,25-1)
sd <- (ME/t)*5
sd
## [1] 17.53481

SAT scores. (7.14, p. 261) SAT scores of students at an Ivy League college are distributed with a standard deviation of 250 points. Two statistics students, Raina and Luke, want to estimate the average SAT score of students at this college as part of a class project. They want their margin of error to be no more than 25 points.

  1. Raina wants to use a 90% confidence interval. How large a sample should she collect?
Z<-1.65
sd<-250
ME<-25
#ME=Z*SE=Z*(sd/sqrt(n))
n<-((Z*sd)^2)/ME^2
n
## [1] 272.25

Raina need 273 samples.

  1. Luke wants to use a 99% confidence interval. Without calculating the actual sample size, determine whether his sample should be larger or smaller than Raina’s, and explain your reasoning.

Answer: He should need larger sample because he want to use 99% confidence interval, so the Z will be larger.

  1. Calculate the minimum required sample size for Luke.
Z<-2.58

#ME=Z*SE=Z*(sd/sqrt(n))
n<-((Z*sd)^2)/ME^2
n
## [1] 665.64

Luke need 666 samples.


High School and Beyond, Part I. (7.20, p. 266) The National Center of Education Statistics conducted a survey of high school seniors, collecting test data on reading, writing, and several other subjects. Here we examine a simple random sample of 200 students from this survey. Side-by-side box plots of reading and writing scores as well as a histogram of the differences in scores are shown below.

  1. Is there a clear difference in the average reading and writing scores?

Answer: No. There is no clear difference in the average reading and writing, but we can see the median of reading is higher than writing.

  1. Are the reading and writing scores of each student independent of each other?

Answer: No. Reading and writing scores might dependent on each other. Better reader might have better scores of writing.

  1. Create hypotheses appropriate for the following research question: is there an evident difference in the average scores of students in the reading and writing exam?

Answer:\(H_0\): there is no difference in the average scores of students in the reading and writing exam \(H_A\): there is a difference in the average scores of students in the reading and writing exam

  1. Check the conditions required to complete this test.

Answer: There are 200 students’ score and they are randomly collected. The boxplot shows there isn’t any extremely outliers, so the conditions satisfy. The two sets of observations have this special correspondence, so they are said to be paired.

  1. The average observed difference in scores is \({ \widehat { x } }_{ read-write }=-0.545\), and the standard deviation of the differences is 8.887 points. Do these data provide convincing evidence of a difference between the average scores on the two exams?
# Compute Standard error
SE<-8.887/sqrt(200)
# Compute T statistic
T<-(-0.545-0)/SE

#p value. 
p <- 2*pt(T, 199)
p
## [1] 0.3868365

Answer: P value greater than 0.05, so we fail to reject \(H_0\), and we do not have convincing evidence of a difference between the average reading and writing exam scores.

  1. What type of error might we have made? Explain what the error means in the context of the application.

Answer: If we fail to \(H_0\), we might have type 2 error when the alternative is actually true. It means there is a difference in the average scores of students in the reading and writing exam.

  1. Based on the results of this hypothesis test, would you expect a confidence interval for the average difference between the reading and writing scores to include 0? Explain your reasoning.

Answer: Yes, we will expect a confidence interval for the average difference between the reading and writing scores to include 0. From the p value, we fail to reject \(H_0\),which means there is no difference in the average scores of students in the reading and writing exam.


Fuel efficiency of manual and automatic cars, Part II. (7.28, p. 276) The table provides summary statistics on highway fuel economy of cars manufactured in 2012. Use these statistics to calculate a 98% confidence interval for the difference between average highway mileage of manual and automatic cars, and interpret this interval in the context of the data.

\(H_0\):There is no difference between average highway mileage of manual and automatic cars. \(H_A\):There is a difference between average highway mileage of manual and automatic cars.

n <- 26

# Manual
mean_m <- 27.88
sd_m <- 5.01

# Automatic
mean_a <- 22.92
sd_a <- 5.29

# Standard Error
SE<- ( (sd_a ^ 2 / n) + ( sd_m ^ 2 / n) ) ^ 0.5

meandif<-mean_m-mean_a

# T value of 98% confidence interval
T<-qt(0.01,df=25)
T<--T

lower<-meandif-T*SE
higher<-meandif+T*SE

c(lower,higher)
## [1] 1.409078 8.510922

The 98% confidence interval for the difference between average highway mileage of manual and automatic cars fall between 1.41 and 8.51.


Email outreach efforts. (7.34, p. 284) A medical research group is recruiting people to complete short surveys about their medical history. For example, one survey asks for information on a person’s family history in regards to cancer. Another survey asks about what topics were discussed during the person’s last visit to a hospital. So far, as people sign up, they complete an average of just 4 surveys, and the standard deviation of the number of surveys is about 2.2. The research group wants to try a new interface that they think will encourage new enrollees to complete more surveys, where they will randomize each enrollee to either get the new interface or the current interface. How many new enrollees do they need for each interface to detect an effect size of 0.5 surveys per enrollee, if the desired power level is 80%?

Answer: Z-score that give us a lower tail of 80% would be about Z=0.84. Additionally, the rejection region extends 1.96* SE from the center of the null distribution for sigma= 0.05. This allow us to calculate the target distance between the center of the null and alterative distributions in terms of the standard error: 0.84SE+1.96SE=2.8SE, so 0.5=2.8SE.

#SE<- sqrt( (2.2^2 / n) + ( 2.2^2 / n) )
n = (2.8^2/(0.5)^2)*(2.2^2+2.2^2)
n
## [1] 303.5648

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.

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

Answer: \(H_0\):Average number of hours worked is identical in all five groups \(H_A\):Average number of hours worked is various by groups

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

Answer: The data from all 1,172 respondents are independent across groups. The data within each group are nearly normal and the variability across the groups is about equal.

  1. Below is part of the output associated with this test. Fill in the empty cells.
mean <- c(38.67, 39.6, 41.39, 42.55, 40.85)
sd <- c(15.81, 14.97, 18.1, 13.62, 15.51)

n<-1172
k<-5

df_G <- k - 1
dfResidual<- n - k
dfResidual
## [1] 1167
Prf <- 0.0682
MSG <- 501.54
SSE <- 267382

#MSG=(1/df_G)*SSG
SSG<-MSG*df_G


#MSE=(1/dfResidual)*SSE
MSE<-SSE/dfResidual

#F value
f_value<-MSG/MSE

#SSE=SST-SSG
SST<-SSE-SSG


  
Df <- c(df_G, dfResidual,df_G+dfResidual)
Sum_Sq<- c(SSG, 267382, SSG+267382)
Mean_Sq <- c(501.54, round(MSE,2),NA)
F_value <- c(round(f_value,2), NA, NA)
Pr<- c(0.0682,NA,NA)

df<- data.frame(Df, Sum_Sq, Mean_Sq, F_value, "Pr>f" = Pr)
row.names(df) <- c("degree", "Residuals", "Total")
df
##             Df    Sum_Sq Mean_Sq F_value   Pr.f
## degree       4   2006.16  501.54    2.19 0.0682
## Residuals 1167 267382.00  229.12      NA     NA
## Total     1171 269388.16      NA      NA     NA
  1. What is the conclusion of the test?

Answer: Since the P value is 0.0682 and higher than the 0.05, we can’t reject null hypothesis Average number of hours worked is identical in all five groups.