OpenIntro Statistics 3rd Ed. (Chapter 5:Inference for Numerical Data )

Q 5.6 Working bakwards, 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.

n <-  25
x1 <- 65
x2<- 77
samplemean <- (x2 + x1)/2
samplemean
## [1] 71

Sample Mean: 71

Marginerror <- (x2 -x1)/2
Marginerror
## [1] 6

Margin of error = 6

n <- 25

Q. 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? Tscore will be 1.65 for 90% confidence interval

#Use Margin error formula with T Score
t <- 1.65
sd <-250
ME <-25

((t*sd)/ME)^2
## [1] 272.25

She should collect a sample of 272

  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 should be larger than Raina’s

  2. Calculate the minimum required sample size for Luke.

t <- 2.575
sd <-250
ME <-25

((t*sd)/ME)^2
## [1] 663.0625

The minimum sample size for Luke is 663

Q. 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 di↵erences in scores are shown below.

a.Is there a clear di↵erence in the average reading and writing scores? Yes, there are clear differences of reading and writing scores since the histogram distribution is normal, away from 0

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

  2. Create hypotheses appropriate for the following research question: is there an evident di↵erence in the average scores of students in the reading and writing exam? H0 = There is no difference in reading and writing scores Ha = There is a difference in reading and writing scores

  3. Check the conditions required to complete this test.

  1. independence of observations 2.Observations come from nearly normal distribution
  1. The average observed di↵erence in scores is 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?
sdiff <- 8.887
ndiff <- 200
xdiff <- .545

SEdiff <- sdiff/ sqrt(ndiff)
SEdiff
## [1] 0.6284058
T <- (xdiff-0)/ SEdiff
T
## [1] 0.867274
n <- 200
df <-n-1
p <- pt(T, df = df)
p
## [1] 0.8065818

Since the pvalue is greater than .05, we accept the null hypothesis - There is a difference in the reading and writing scores

What type of error might we have made? Explain what the error means in the context of the application. We may have incorrectly rejected the alternative hypothesis

Based on the results of this hypothesis test, would you expect a confidence interval for the average diffrence between the reading and writing scores to include 0? Explain your reasoning. No I would not expect the confidence interval to include 0 since their is a differnece between reading and writing scores

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

H0 = The difference between average fuel efficiency is 0 Ha = The difference between average fuel efficiency is not 0

xA <- 16.12
xB <- 19.85
pointest <- xA-xB
pointest
## [1] -3.73
sdA <- 3.58
sdB <- 4.51


n<- 26
SE <- sqrt((sdA^2/26)+(sdB^2/26))
SE
## [1] 1.12927
T <- (pointest - 0)/ SE
T
## [1] -3.30302

df = 25

df <- 25
p <- pt(T, df = df)
p
## [1] 0.001441807

The p value is smaller than 0.05 so we can reject the null hypothesis There is a difference between average fuel efficiency

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 = Average numbers of hourse are identical Ma = Mb = Mc Ha = Average number of hours worked varies

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

  1. Observations are independent
  2. Data is nearly normal
  3. Variables across groups is nearly normal
  1. Below is part of the output associated with this test. Fill in the empty cells.
mu <- c(38.67, 39.6, 41.39, 42.55, 40.85)
sd <- c(15.81, 14.97, 18.1, 13.62, 15.51)
n <- c(121, 546, 97, 253, 155)
k <- 5
MSG <- 501.54
SSE <- 267382
n <- sum(n) - k
n
## [1] 1167
p <- 0.0682
#Find Df
dfG <- k-1
dfE <- n-k
dfT <- dfG + dfE
df <- c(dfG, dfE, dfT)
# Find Sum Sq
SSG <- dfG * MSG
SST <- SSG + SSE
SS <- c(SSG, SSE, SST)
# Find Mean Sq
MSE <- SSE / dfE
MS <- c(MSG, MSE, NA)
# Find F-value
Fv <- MSG / MSE
df <- data.frame(df, SS, MS, c(Fv, NA, NA), c(p, NA, NA))
colnames(df) <- c("Df", "Sum Sq", "Mean Sq", "F Value", "Pr(>F)")
rownames(df) <- c("degree", "Residuals", "Total")
df [1:5]
##             Df    Sum Sq Mean Sq  F Value Pr(>F)
## degree       4   2006.16 501.540 2.179614 0.0682
## Residuals 1162 267382.00 230.105       NA     NA
## Total     1166 269388.16      NA       NA     NA

What is the conclusion of the test? The p value is greater than .05, the null hypothesis is rejected and there is not a significant difference between the groups

Since the P value is 0.0684 this is too high to reject the null hypothesis at the 0.05 significance level. We must accept the null hypothesis that the mean study hours for each population are the same.