Graded: 5.6, 5.14, 5.20, 5.32, 5.48
##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
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
Luke’s sample should be larger since z value for 99% confidence interval is higher, which is 2.575
## 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
Picture
The difference in the average of reading and writing scores is not clear. The distribution looks fairly normal and centered around zero.
Due to the observations are paired,the reading and writing scores of each student are NOT independent of each other.
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.
\({ \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.
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.
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.
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.
Ho: All the groups having same mean
HA: Atleast one of the mean is different.
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 |
The p-value is 0.06882.
Due to the p-value > 0.05 we do not reject the null hypothesis.