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

#Sample Mean
sample_mean <- ((65+77)/2)
sample_mean
## [1] 71
#Margin of error
n <- 25
deg<-n-1
deg
## [1] 24
t <- qt(0.95,deg)

Mar_Err<-((77-65)/2)
Mar_Err
## [1] 6
#SD
sd <- ((Mar_Err*sqrt(n))/t)
sd
## [1] 17.53481

Question 5.14

SAT scores. 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.
(a) Raina wants to use a 90% confidence interval. How large a sample should she collect?

sd=250
ME=25
# 90% confidence interval
zscore <- qnorm(0.95)

#zscore
n=((zscore*sd/ME)^2)
n
## [1] 270.5543

270 Sample size collected
(b) 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.
Luke sample size has be larger than Raina, since it will require a higher z number multiplied by the standard deviation (c) Calculate the minimum required sample size for Luke.

sd<-250
Mar_err<-25
# 99% confidence interval
zscore <- qnorm(0.99)
## [1] 2.345531
#zscore
n=((zscore*sd/Mar_err)^2)
n 
## [1] 541.1894
541 Sample size collected

Question 5.20

High School and Beyond, Part I. 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.

(a) Is there a clear difference in the average reading and writing scores?
There is no clear difference in the average of the reading and writing scores. The difference in distribution is normal and has no difference

(b) Are the reading and writing scores of each student independent of each other?
Reading and writing scores are not independent of each other for each student, the scores are independent of each student

(c) 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?

H0:xread-write =0
H1:xread-write!=0

(d) Check the conditions required to complete this test.

1.Samples seem all independent (survey was from 200 random sample)
2.Nearly normal distribution, the sample size should be 30 to check the skewness

(e) The average observed difference in scores is ¯xread???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?

sd<- 8.887
mu <- -0.545
n <- 200

se<- sd / sqrt(n)

t<- (mu - 0) / se

df <- n - 1

p <- pt(t, df = df)
p
## [1] 0.1934182


p value is not a clear evidence of a difference in student’s reading and writing exam scores for H(o).
(f) What type of error might we have made? Explain what the error means in the context of the application.
Type II: Incorrectly failed to reject the alternative hypothesis.
(g) 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.
Yes, because H0 is rejected


Question 5.32

Fuel efficiency of manual and automatic cars, Part I. Each year the US Environmental Protection Agency (EPA) releases fuel economy data on cars manufactured in that year. Below are summary statistics on fuel efficiency (in miles/gallon) from random samples of cars with manual and automatic transmissions manufactured in 2012. Do these data provide strong evidence of a difference between the average fuel efficiency of cars with manual and automatic transmissions in terms of their average city mileage? Assume that conditions for inference are satisfied.

n <- 26
mu_auto <- 16.12
sd_auto <- 3.58

mu_manual <- 19.85
sd_manual <- 4.51

#difference
mu_diff <- mu_auto - mu_manual

#standard error
se_diff <- ((sd_auto^2/n) + ( sd_manual^2/n))^0.5

t <- (mu_diff - 0) / se_diff
df <- n - 1
p <- pt(t, df = df)
p
## [1] 0.001441807


H0 is rejected (p < 0.05)


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


  1. Write hypotheses for evaluating whether the average number of hours worked varies across the five groups. H0: The mean is the same across all group.
    H1: One mean is different
    (b) Check conditions and describe any assumptions you must make to proceed with the test.
    The independent data are within the groups and looks nearly normal

(c) 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.45)
SD <- c(15.81, 14.97, 18.1, 13.62, 15.51)
n <- c(121, 546, 97, 253, 155)

n <- sum(n)
k <- 5

df <- k - 1
dfr <- n - k

Prf <- 0.0682
F1 <- qf( 1 - Prf, df , dfr)

msg <- 501.54
mse <- msg / F1

ssg <- df * msg
sse <- 267382

#sst = ssg + sse,  
#df_Total = df + dfr

sst <- ssg + sse
dft <- df + dfr

(d) What is the conclusion of the test?

p value = 0.0682,which is higher than 0.05,so dont reject the null hypothesis.