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.

(65+77)/2 #sample mean
## [1] 71
77-71 #margin of error
## [1] 6
t24 <- qt(p=.90, df=25-1) #the Student t Distribution, critical value

Using the formulas \(ME = t_{24}* SE\) and \(SE = \frac{s}{\sqrt{n}}\)

We obtain \(s = \frac{ME\sqrt{n}}{t_{24}}\)

6*sqrt(25)/t24 #sample standard deviation
## [1] 22.76459

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?

For a 90% confidence interval, the z-score = 1.645 Since \(ME = Z*\frac{\sigma}{\sqrt{n}}\)

We obtain \(n = (\frac{Z*\sigma}{ME})^2\)

(1.645*250/25)^2 #n
## [1] 270.6025

Raina’s sample size should be at least 271.

  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.

Since the z-score for a 99% confidence interval is greater than the z-score for a 90% confidence interval, the sample size would be larger.

  1. Calculate the minimum required sample size for Luke.

For a 99% confidence interval, the z-score = 2.576

(2.576*250/25)^2
## [1] 663.5776

Luke’s sample size should be at least 664.


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.

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

There is no clear difference in the average reading and writing scores.

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

Unlikely, as reading and writing scores have correspondence, they are said to be paired.

  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?

\(H_0:\) There is no difference between the average reading and writing score \(\mu_{diff} = 0\)

\(H_1:\) There is no difference between the average reading and writing score \(\mu_{diff} \ne 0\)

  1. Check the conditions required to complete this test.

The distribution is not skewed. If stuents were sampled randomly and are less than 10% of all student population, we can assume that the difference between the reading and writing scores of one student in the sample is independent of another.

  1. The average observed difference in scores is \(\bar{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?

Using formula \(Z = \frac{-0.545-0}{\frac{8.887}{\sqrt{200}}} = -0.87\)

(-0.545-0)/(8.887/sqrt(200)) #Z-score
## [1] -0.867274

The corresponding probability is 0.1949, so \(p-value = 0.1949*2 = 0.3898\)

0.1949*2
## [1] 0.3898

Using \(\alpha = 0.05\) p-value 0.3898 > 0.05, thus fail to reject null hypothesis. The data do not provide convincing evidence of a difference between the average reading and writing scores.

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

Type II Error. We concluded there is no difference between the average reading and writing scores but in fact there is.

  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.

Yes, since \(-0.545\pm1.96\frac{8.887}{\sqrt{200}} = (-1.775, 0.685)\) 0 is included in the interval.


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.

\(\bar{x}_{Auto} = 16.12\) \(\bar{x}_{Manual} = 19.85\)
\(\sigma_{Auto} = 3.58\) \(\sigma_{Manual} = 4.51\) \(n_{Auto} = 26\) \(n_{Manual} = 26\)

Standard error of the difference between two sample means: \(SE_{(\bar{x}_{Manual}-\bar{x}_{Auto})} = \sqrt{\frac{3.58^2}{26}+\frac{4.51^2}{26}} = 1.129\)

sqrt(sum(3.58^2/26, 4.51^2/26))
## [1] 1.12927

\(Z = \frac{(\bar{x}_{Manual}-\bar{x}_{Auto})-0}{SE_{(\bar{x}_{Manual}-\bar{x}_{Auto})}} = 3.3\)

(19.85-16.12-0)/1.129
## [1] 3.303809

\(Z = 3.3\) The corresponding probability is 0.995 \(upper tail = 1 - 0.995 = 0.005\) \(p-value = 0.005 X 2 = 0.01\)

Using \(\alpha = 0.05\) p-value 0.01 < 0.5, thus we reject the null hypothesis.

We concluded that 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


5.48 Work hours and education. The General Social Survey collects data on demographics, education, and work, among many other characteristics of US residents. 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.

5.48.1

5.48.1

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

\(H_0:\) Average number of hours worked is the same across the five groups. \(H_1:\) Average number of hours worked is different from at least one of the five groups.

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

We need to check if the respondents were selected randomly. 1172 is less than 10% of the population, so that’s good and we can assume independence within and across all groups.

  1. Below is part of the output associated with this test. Fill in the empty cells.
5.48.2

5.48.2

Df_degree <- 5-1 #number of groups - 1
Df_Total <- 1172 - 1 #number of total sample size(n) - 1
Df_Residuals <- Df_Total - Df_degree
Df <- c(Df_degree, Df_Residuals, Df_Total)

Df_degree = 4, Df_Residuals = 1167, Df_Total = 1171

SSG = sum of squares between groups = 2004 \(SSG = \sum_{i=1}^{k} n_{i}(\bar{x}_{i}-\bar{x})^2\)

x <- 40.45
SSG <- round(121*(38.67-x)^2 + 546*(39.6-x)^2 + 97*(41.39-x)^2 + 253*(42.55-x)^2 + 155*(40.85-x)^2)

SST = sum of squares total = 269,386.1 \(SST = \sum_{i=1}^{n} (x_{i}-\bar{x})\) In this case, we can simply add SSG and SSE(sum of squares error) to get SST

SSE <- 267382
SST <- SSG + SSE
SumSq <- c(SSG, SSE, SST)

MSE = mean square error = 229.12 (MSE for Residuals) Mean square error is calculated as sum of squares divided by the degrees of freedom.

MSG <- 501.54
MSE <- round(SSE / Df_Residuals, 2)
MeanSq <- c(MSG, MSE, NA)

F value, test statistic = 2.19 The F statistic is the ratio of the between group and within group variability \(F = \frac{MSG}{MSE}\)

F <- round(MSG / MSE, 2)
Fvalue <- c(F, NA, NA)
p <- 0.0682
Pvalue <- c(p, NA, NA)
  1. What is the conclusion of the test?

p-value is 0.0682 > 0.05, fail to reject null hypothesis. The data do not provide convincing evidence that at least one pair of means are different from each other, the observed differences in sample means are attributable to the sampling variability (or chance).

The complete table:

ANOVA <- data.frame(Df, SumSq, MeanSq, Fvalue, Pvalue)
colnames(ANOVA) <- c("Df", "SumSq", "MeanSq", "F Value", "Pr(>F)")
rownames(ANOVA) <- c("degree", "Residuals", "Total")

library(DT)
datatable(ANOVA)