Problem 1

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.

ci_lower <- 65
ci_upper <- 77
zvalue <- qnorm(0.95)
n <- 25

sample_mean <- (ci_upper - ci_lower)/2 + ci_lower
me <- sample_mean - ci_lower

#Use t-value 
# me = tvalue * (sd/sqrt(n))
df <- n - 1
p <- 0.95   #0.90, but two tailed so use 0.95
tvalue <- qt(p,df)
  
std_dev <- me/(tvalue/sqrt(n))

cat('Sample mean:', sample_mean, 'Margin of error:', me, 'standard deviation:', std_dev)
## Sample mean: 71 Margin of error: 6 standard deviation: 17.53481

Problem 2

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?
#me = zvalue * sd/sqrt(n)
sd = 250
me = 25
zvalue = qnorm(0.95)

n <- round(((zvalue * sd)/me)**2)
cat('Sample size should be at least', n)
## 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. Luke’s sample size needs to be larger because the confidence level and the sample size are positively correlated. This makes sense given that the sample size is part of the denominator.

  2. Calculate the minimum required sample size for Luke.

zvalue = qnorm(0.995)

n <- round(((zvalue * sd)/me)**2)
cat('Sample size should be at least', n)
## Sample size should be at least 663

Problem 3

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? Yes. The writing score average looks to be around 10 points higher than the reading average.

  2. Are the reading and writing scores of each student independent of each other? The observations are based on a simple random sample, so independence is reasonable.

  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? H0: avg reading = avg writing (R = W) H1: avg reading != avg writing (R != W)

  4. Check the conditions required to complete this test. Per the histogram the differences between reading and writing scores appear to be normally distributed. The data can also be assumed to be independent since it is based on a random sample.

  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? The tvalue computed below is 0.19 which is > 0.05, so there is not convincing evidence of a difference.

rwmean = -0.545
rwsd = 8.887
n = 200

se = rwsd/sqrt(n)

T <- (rwmean - 0)/se

tvalue <- pt(T, n-1)
tvalue
## [1] 0.1934182
  1. What type of error might we have made? Explain what the error means in the context of the application. It’s possible that a False Negative (null hypothesis is wrong, but we say it’s right) was made. If an error was made then there is significant difference between the average scores on the exams.

  2. 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. The mean was already close to 0 at -0.545, and given the large standard deviation, I’d expect 0 to be in the confidence interval range.


Problem 4

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.

meana = 22.92
meanm = 27.88
meandiff = meanm - meana

sda = 5.29
sdm = 5.01

n = 26  #each sample has same n

tvalue = qt(0.99, n-1)

SEa = sda/sqrt(n)
SEm = sdm/sqrt(n)

SE = meandiff/(SEa + SEm)

lower_bound = round(meandiff - (tvalue * SE))
upper_bound = round(meandiff + (tvalue * SE))

cat('We can be 98% confident that the avg mpg difference of manual and automatic cars is between', lower_bound, 'and', upper_bound, 'miles')
## We can be 98% confident that the avg mpg difference of manual and automatic cars is between -1 and 11 miles

Problem 5

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

zvalue = qnorm(0.8)  #desired power leve is 80%

significancelevel = qnorm(0.975)  #95% significance level

zvalue_times_siglevel = zvalue + significancelevel

effectsize = 0.5
sd = 2.2

#from page 282 of book
n = ((zvalue_times_siglevel**2)/(effectsize**2)) * (sd**2 + sd**2)
cat('Number of new enrollees needed is', round(n))
## Number of new enrollees needed is 304

Problem 6

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: g1 = g2 = g3 = g4 = g5 H1: At least one of the groups is not equal to the others

  2. Check conditions and describe any assumptions you must make to proceed with the test. Assuming that the sample data is randomly collected, so independent

That the distribution is approximately normal - from the boxplots it is apparent there are outliers, but the number of them relative to the sample size of 1172 is low.

That the variance between the groups is constant. From the boxplot this appears to be the case.

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

df1 = k - 1 where k is the number of groups. So df1 = 4 df2 = n - k, so 1172 - 5 = 1167 Total = n - 1 so 1172 - 1 = 1171

Sum Squares = MST * df1 = 501.54 * 4 = 2006.16 Total = SST + SSE = 2006.16 + 267382 = 269588.16

Mean Squares = SSE/df2 = 267382/1167 = 229.12

F-Value = MST/MSE = 501.54/229.12 = 2.18

  1. What is the conclusion of the test? The F-value of 2.18 is not particularly high and the p-value of 0.07 > a 0.05 significance level. As a result the conclusion is that H0 cannot be rejected, so there is not sufficient evidence to conclude that the means across the groups are different for reasons other than chance.