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.

n <- 25
x1 <- 65
x2 <- 77

sample_mean <- (x1 + x2) / 2
# sample mean
sample_mean
## [1] 71
moe <- (x2 - x1) / 2
# margin of error
moe
## [1] 6
p_two_tailed <- .9 + (1-.9)/2

t_stat <- qt(p_two_tailed,24)

std_err <- moe/t_stat

std_dev <- std_err * sqrt(n)
# standard deviation
std_dev
## [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?
  2. 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.
  3. Calculate the minimum required sample size for Luke.

Answers:
a.

Z <- 1.65
moe <- 25
std_dev <- 250

n <- ((Z*std_dev)/moe)^2
# Number of students
ceiling(n)
## [1] 273

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?
    The mean of the writing score is slightly higher than the reading score, but overall there is not a clear difference.
  2. Are the reading and writing scores of each student independent of each other?
    Since the “differences in scores” distribution is normal with the peak at zero, the reading and writing scores are usually around the same, so they are likely not independent of each other.
  3. 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: The mean difference in each student’s reading and writing scores is zero.
    H_a: The mean difference in each student’s reading and writing scores is not zero.
  4. Check the conditions required to complete this test.
    Independence: if the student’s scores are not independent of each other, this condition may be threatened.
    Normal distribution: The histogram seems like a close approximation of a normal distribution.
  5. 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?
mean_diff <- -0.545
std_dev <- 8.887
n <- 200 # sample size

std_err <- std_dev / sqrt(n)

t_stat <- mean_diff / std_err

p <- pt(t_stat, 199)
p
## [1] 0.1934182

P-value is greater than 0.05 so we reject the alternative hypothesis.
(f) What type of error might we have made? Explain what the error means in the context of the application.
We might have made a type 2 error by rejecting the alternative hypothesis, the error would mean that we wrongly conclude that the mean difference in each student’s reading and writing scores is zero.
(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.
I would expect the confidence interval for this test to include zero as the mean difference of the sample is very close to zero with a relatively wide standard deviation interval.


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.

Answer

n <- 26
x1 <- 22.92
x2 <- 27.88
s1 <- 5.29
s2 <- 5.01

df <- 49 # Not given that variances are equal.

t_crit <- 2.4049 # For the 0.02 level of significance.

SE <- sqrt((s1^2/n)+(s2^2/n))

high <- x1-x2+t_crit*SE
low <- x1-x2-t_crit*SE

interval <- c(low,high)
interval
## [1] -8.396315 -1.523685

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%?

s <- 2.2
ci <- 0.5
alpha <- 0.05
beta <- 0.2
z_alpha <- qnorm(alpha/2)
z_beta <- qnorm(beta)

n <- 2 * ((z_alpha+z_beta)^2*s^2/0.5^2)
ceiling(n) # Number of new enrollees.
## [1] 304

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.
  2. Check conditions and describe any assumptions you must make to proceed with the test.
  3. Below is part of the output associated with this test. Fill in the empty cells.
  1. What is the conclusion of the test?

Answers:
a.
H_0: The difference between all averages is zero.
H_a: One or more averages are different from the others.
b.
We must assume a normal distribution, independence of observations, and close to equal varability across the groups.
c.

ed_attain <- c('Less than HS', 'HS','Jr Coll','Bachelors','Graduate')
resp_means <- c(38.67, 39.6, 41.39, 42.55, 40.85)
resp_std_dev <- c(15.81, 14.97, 18.1, 13.62, 15.51)
n <- c(121, 546, 97, 253, 155)
educ_surv_table <- data.frame(resp_means, resp_std_dev, n, row.names = ed_attain)
educ_surv_table
##              resp_means resp_std_dev   n
## Less than HS      38.67        15.81 121
## HS                39.60        14.97 546
## Jr Coll           41.39        18.10  97
## Bachelors         42.55        13.62 253
## Graduate          40.85        15.51 155
k <- 5
n <- sum(educ_surv_table$n)
df <- k-1
df_res <- n-k

pr_f <- 0.0682
f_stat <- qf(1-pr_f,df,df_res)

mean_sq_deg <- 501.54
mean_sq_res <- mean_sq_deg/f_stat

sum_sq_deg <- df * mean_sq_deg
sum_sq_res <- 267382

df_table <- c(df, df_res,df_res)
sum_sq_table <- c(sum_sq_deg, sum_sq_res,sum_sq_deg+sum_sq_res)
mean_sq_table <- c(mean_sq_deg,mean_sq_res,NA)
f_table <- c(f_stat,NA,NA)
prf_table <- c(pr_f,NA,NA)
anova_names <- c('degree','Residuals','Total')

filled_table <- data.frame(df_table,sum_sq_table,mean_sq_table,f_table,prf_table, row.names = anova_names)
filled_table
##           df_table sum_sq_table mean_sq_table  f_table prf_table
## degree           4      2006.16      501.5400 2.188931    0.0682
## Residuals     1167    267382.00      229.1255       NA        NA
## Total         1167    269388.16            NA       NA        NA
  1. P-value 0.0682 is greater than 0.05, we reject the alternative hypothesis and concluded that there is no significant difference between the groups.