1. Confidence interval is an interval computed using sample information that estimates the
value of a population parameter. Thus the primary use of a confidence interval is to
estimate a true, unknown population parameter.
Bootstrap is an alternative for obtaining confidence intervals for the mean using the non
parametric approach. The variables in the data are almost all not normally distributed,
therefore we need bootstrap in R to do it.
The idea is as follows:
1. Resample with replacement B times.
2. For each of these samples calculate the sample mean.
3. Calculate an appropriate bootstrap confidence interval.
Thisis the program to runthe bootstrapinR
library(boot)
Bmean<- function(data,indices){
d <- data[indices]
return(mean(d))
}
results<- boot(data=data0,statistic=Bmean,R=1000)
boot.ci(results,type=c("norm","basic","perc","bca"))
2. Normal Distribution Confidence Interval
The variabel that is normally distributed is only GPA. Therefore we can
perform confidence interval with parametric approach which means without
using bootstrap.By using 5% significance level,
We take 1 − α = 0.95, So we have:
𝑃(−𝑧 ≤ 𝑍 ≤ 𝑧) = 1 − 𝛼 = 0.95
so, we have
Φ( 𝑧) = 𝑃( 𝑍 ≤ 𝑧) = 1 −
𝛼
2
= 0.975
𝑧 = Φ−1
(Φ(z)) = Φ−1(0.975) = 1.96
So, to obtain the confidence interval
0.95 = 1 − 𝛼 = 𝑃(−𝑧 ≤ 𝑍 ≤ 𝑧) = 𝑃(−1.96 ≤
𝑋̅ − 𝜇
𝜎
𝑛⁄
≤ 1.96
= 𝑃(𝑋̅ − 1.96
𝜎
√ 𝑛
≤ 𝜇 ≤ 𝑋̅ + 1.96
𝜎
√ 𝑛
error <- qnorm(0.975)*s/sqrt(n)
left <- a-error
right <- a+error
> left
[1] 3.035062
> right
[1] 3.222938
The confidence Interval for GPA is 3.035062 and 3.222938
GPA
Min. :2.300
1st Qu.:2.900
Median :3.150
Mean :3.129
3rd Qu.:3.400
Max. :3.900
stdev = 0.3773884
samplesize = 62