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.

Answer:

Sample Mean

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

Critical t score

t_score <- qt(0.05, df = 24)
t_score <- t_score*-1
t_score
## [1] 1.710882

Confidence Interval
(C1,C2) = x_mean +/- t_scoreSE
C2 = x_mean + t_score
SE

Standard Error
SE = (c2 - x_mean)/ t_score

SE <- (77 - x_mean) / t_score
SE 
## [1] 3.506963

Standard Deviation
SE = SD/sqrt(n)

n <- 25
SD <- SE*sqrt(n)
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.

(a) Raina wants to use a 90% confidence interval. How large a sample should she collect?

Margin of Error ME = z_score * SD/sqrt(n)

Sample Size

SD <- 250
ME <- 25
z_score <- 1.645

n <-(z_score*SD/ME)**2
n  
## [1] 270.6025

(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.
The greater confidence increase will increase the z_score and therefore the sample size.

(c) Calculate the minimum required sample size for Luke.

SD <- 250
ME <- 25
z_score <- 2.58

n <-(z_score*SD/ME)**2
n  
## [1] 665.64

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.

(a) Is there a clear difference in the average reading and writing scores?
No, there is no clear difference between the reading and writing scores.
(b) Are the reading and writing scores of each student independent of each other?
No, the reading and writing scores are not independent.
(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?
Null Hypothesis: Difference between reading and writing score is 0. The alternate hypothesis: Difference between reading and writing score does not equal 0.

(d) Check the conditions required to complete this test.
Independence: Sample of students was random
Normality: N is greater than or equal to 30. Based on the difference the distribution is normal. The box plot indicates that there are no particularly extreme outliers.
(e) 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?

s_diff <- 8.887 
x_diff <- -0.545
n_diff <- 200

t_score <- (x_diff - 0)/(s_diff/sqrt(n_diff))


2*pt(t_score, df = n_diff-1, lower.tail = FALSE )
## [1] 1.613164

The p-value is greater than 5%, therefore we cannot reject the null 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 failing to reject the null hypothesis when the alternate is true.

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

c1 <- x_diff - t_score*(s_diff/sqrt(n_diff))

c2 <- x_diff + t_score*(s_diff/sqrt(n_diff))

c1
## [1] 0
c2
## [1] -1.09

No, 0 does not fall in between the confidence interval calculated.


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.

Given Values, Standard Error, T Score

n_diff <- 26

x_diff <- 22.92-27.88


se_diff <- sqrt((5.29^2)/n_diff + (5.01^2)/n_diff)

t_score <- qt(.02/2, df=n_diff-1)

Confidence Interval for 98%

c1 <- x_diff + t_score*se_diff
c2 <- x_diff - t_score*se_diff
c1
## [1] -8.510922
c2
## [1] -1.409078
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%?
Given values
r x <- 4 sd <- 2.2 z_score80 <- .844
Calculating the standard error .84se+1.96se = 0.5
r se <- 0.5/(.84+1.96)
Calculating number of enrollees
se = sqrt(sd^2/n + sd^2/n)
r n <- (sd^2+sd^2)/se^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.

(a) Write hypotheses for evaluating whether the average number of hours worked varies across the five groups.
The mean of the hours study across groups are equal. h_o: h_lhs = h_hs = h_jc = h_b = h_g.

(b) Check conditions and describe any assumptions you must make to proceed with the test. We assume the following:
Observations are independent within and across groups.
The data within each group are nearly normal.
The variability across the groups is about equal.

(c) Below is part of the output associated with this test. Fill in the empty cells.

Degree of Freedoms: g = Group, t = total, e = error

df_g <- 5-1
df_t <- 1172-1
df_e <- df_t - df_g

df_g
## [1] 4
df_e
## [1] 1167
df_t
## [1] 1171

Sum of the Square - Group and Total

ssg <- sum(121*(38.67-40.45)^2, 546*(39.6-40.45)^2, 97*(41.39-40.45)^2, 
           253*(42.55-40.45)^2, 155*(40.85-40.45)^2)

sst <- ssg + 267382

ssg
## [1] 2004.101
sst
## [1] 269386.1

Mean Square - Error

mse = 267382/df_e
mse
## [1] 229.1191

F-Value

f <- 501.54/mse
f
## [1] 2.188992

(d) What is the conclusion of the test?
Because the p-value is greater than .05 we cannot reject the null hypothesis.