Graded: 5.6, 5.14, 5.20, 5.32, 5.48

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.

##sample mean
x1<-65
x2<-77

Mean<-(x1+x2)/2
Mean
## [1] 71
##margin error 
x1<-65
x2<-77
ME<-(77-65)/2
ME
## [1] 6
p<-0.9
df<- 24 ##25-1
p_2tails <- p + (1 - p)/2

t_val <- qt(p_2tails, df) ##1.710882

##find standard error
SE <- ME / t_val  ## 3.506963

##Standard deviation

n<-25
sd <- SE * sqrt(n)
sd
## [1] 17.53481

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?

We have:

SD= 250 ME=25

We can use formula ME=z * SE, where

\(SE=\frac { sd }{ \sqrt { n } }\) , therefore

\(ME=\quad z*\frac { sd }{ \sqrt { n } }\) or

\(25=\quad 1.65*\frac { 250 }{ \sqrt { n } }\)

## The sample size
ME<-25
z<- 1.65
sd<-250
n<- ((z*sd)/ME)^2
n
## [1] 272.25

The sample size is 273

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

Luke’s sample should be larger since z value for 99% confidence interval is higher, which is 2.575

(c) Calculate the minimum required sample size for Luke.
## Luke's Sample size

z <- 2.575 
ME <- 25
sd <- 250

n <- ((z * sd) / ME ) ^ 2
n
## [1] 663.0625

The sample size is 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.

Picture

Picture

(a) Is there a clear difference in the average reading and writing scores?

The difference in the average of reading and writing scores is not clear. The distribution looks fairly normal and centered around zero.

(b) Are the reading and writing scores of each student independent of each other?

Due to the observations are paired,the reading and writing scores of each student are NOT independent of each other.

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

H0: There is NO evident difference in the average scores of students in the reading and writing exam. HA: There is an evident difference in the average scores of students in the reading and writing exam.

(d) Check the conditions required to complete this test.

  1. Independence of observations: Differences are taken from the random sample - diffrences are independent
  2. Observations come from nearly normal distribution: Since the sample size is more than 30, observations came from normal distribution.

(e) The average observed difference in scores is

\({ \overline { 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?

sd <- 8.887
m <- -0.545
n <- 200
df <-  199 ##200-1

se <- sd / sqrt(n)
t <-  (m -0)/se

p <- 2*pt(t, df)

p
## [1] 0.3868365

P- value is 0.387, which is not less than 0.05, therefore H0 can not be rejected.

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

We could made the Type II error if we fail to reject the Null hypothesis when there is a difference in the scores and alternative hypothesis 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.

I would expect a confidence interval for the average difference between the reading and writing scores to include 0 due to the H0 could not be rejected.

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

Picture

Picture

The hypotheses for this test are as follows:

H0: There is no difference between the average fuel efficiency of cars with manual and automatic transmissions.

HA: There is a difference between the average fuel efficiency of cars with manual and automatic transmissions.

n<-26
sdA<-3.58
sdM<-4.51
MeanA<-16.12
MeanM<-19.85

Mdiff <- MeanA - MeanM

SE <- ( (sdA^ 2 / n) + ( sdM ^ 2 / n) ) ^ 0.5

t_val <- (Mdiff - 0) / SE
df <- n - 1
p <- pt(t_val, df = df)
p
## [1] 0.001441807

P-value < 0.05, we reject the null hypothesis H0.

There is a difference between the average fuel efficiency of cars with manual and automatic transmissions.

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.

Picture

Picture

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

Ho: All the groups having same mean

HA: Atleast one of the mean is different.

(b) Check conditions and describe any assumptions you must make to proceed with the test.

  1. Independence of observations: The observation within the data is independent
  2. Since the sample size is more than 30, observations came from normal distribution.
  3. The variance in boxplots seems to be consistent across the groups.
(c) Below is part of the output associated with this test. Fill in the empty cells.
Picture

Picture

## Given Data
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)
data_table <- data.frame (mu, sd, n)
data_table
##      mu    sd   n
## 1 38.67 15.81 121
## 2 39.60 14.97 546
## 3 41.39 18.10  97
## 4 42.55 13.62 253
## 5 40.85 15.51 155
n <- sum(data_table$n) #total sample
n
## [1] 1172
n_groups<-5 #number of groups
Dfg<- n_groups-1
Dfe<- n-n_groups
DF_total<-Dfe+Dfg
Dfg
## [1] 4
Dfe
## [1] 1167
DF_total
## [1] 1171
MSG<-501.54 #given value
SSG<-MSG*Dfg
SSG
## [1] 2006.16
SSE<-267382 #given value
SS_total<-SSG+SSE
SS_total
## [1] 269388.2
MSE<-SSE/Dfe
MSE
## [1] 229.1191
F_value<-MSG/MSE
F_value
## [1] 2.188992
p <- pf(q = F_value, Dfg, Dfe, lower.tail = FALSE)
p
## [1] 0.06819325

The value of the test statistic associated with ANOVA test is 2.188992

Table <- data.frame(
  names <- c("degree","Residuals","Total"),
  Df <- c("4","1167","1171"),
  SumSq <- c("2006.16","267382","269388.2"),
  MeanSq <- c("501.54","229.1191",""),
  Fvalue <- c("2.188992","",""),
  PrF <- c("0.0682","","")
)

colnames(Table)<- c("ANOVA","Df","Sum Sq","Mean Sq","F value","Pr(>F)")

knitr::kable(Table)
ANOVA Df Sum Sq Mean Sq F value Pr(>F)
degree 4 2006.16 501.54 2.188992 0.0682
Residuals 1167 267382 229.1191
Total 1171 269388.2
(d) What is the conclusion of the test?

The p-value is 0.06882.

Due to the p-value > 0.05 we do not reject the null hypothesis.