In: Math
Using Rcode solve
A company with a large fleet of cars wants to study the gasoline usage. They check the gasoline usage for 50 company trips chosen at random, finding a mean of 25.02 mpg and sample standard deviation is 4.83 mpg.
a. Which kind of confidence interval is appropriate to use here, z-interval or t-interval?
b. What are the assumptions to check for the interval you chose?
c. Please use R to find the critical value the company needs when constructing a (two-sided) 98% CI.
d. Please use R to construct a (two-sided) 98% CI for the mean of the general gasoline usage.
e. Please use R to construct a 98% upper confidence bound for the mean of the general gasoline usage.
f. Create a R function whose argument is the width of CI, and the output is the sample size necessary to achieve such accuracy. The confidence level is fixed at 98%.
g. Apply the function you created in part (f) to demonstrate that larger sample size is required to achieve better accuracy (i.e, narrower CI width). Confidence level is fixed at 98%. Show at least three examples
Given,
a) We will use z- interval, why, is in the next part.
b) Since, sample size is large (n>30), so, we could preferably use z- interval
Assumptions are:
c).
Confidence level = 98%
Critical value for two sided test is,
qnorm(1-0.02/2) ### this will give
2.326348
For two sided test we have
d).
To construct 98% confidence interval, we develop a function in R,
confint=function(xbar,s,n){
xbar=25.02
s=4.83
n=50
moe=2.33*s/sqrt(n) ### moe is margin of error
Llimit=xbar-moe
Ulimit=xbar+moe
int=c(Llimit,Ulimit)
return(int)
}
confint(xbar,s,n)
23.42846 26.61154
Hence, the inerval is (23.42846 , 26.61154)
e)
For upper bound mean for right tailed test (or one sided test),
confint=function(xbar,s,n){
xbar=25.02
s=4.83
n=50
moe=2.05*s/sqrt(n) ### moe is margin of error
Llimit=xbar-moe
Ulimit=xbar+moe
int=c(Llimit,Ulimit)
return(int)
}
confint(xbar,s,n)
23.61972 26.42028
Hence, the interval is (23.61972 , 26.42028)
Our sampling distribution is normally distributed