Please show R code! Thanks In this problem you are going to analyze the built-in
ID: 3389262 • Letter: P
Question
Please show R code! Thanks In this problem you are going to analyze the built-in R data set iris. First, extract the sepal width of the virginica species and save it to a vector x using this command: x = iris$Sepal.Width[iris$Species == "virginica"] R Code: Using a Gaussian approximation, what is the 05% confidence interval for the mean of x? R Code: Using a Student t distribution, what is the 05% confidence interval for the mean of x? R Code: Now assume that you only have the first 10 measurements. That is, create the vector y = x[l: 10]. Repeat parts (a) and (b) for the vector y. How did the decrease in sample size affect the results? Were the two different confidence intervals affected differently?Explanation / Answer
x=iris$Sepal.Width[iris$Species=="virginica"]
mean(x)
data.frame(x)
a) > qnorm(0.95)
[1] 1.644854
me<- 1.644*(sd(x)/sqrt(50))
> me
[1] 0.07497941
> mean(x)-me
[1] 2.899021
> mean(x)+me
[1] 3.048979
95%confidence interval=(2.899021,3.048979)
b)t.test(x)
Output:
One Sample t-test
data: x
t = 65.208, df = 49, p-value < 2.2e-16
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
2.882347 3.065653
sample estimates:
mean of x
2.974
c)> y=x[1:10]
ca)
> me<- 1.644*(sd(y)/sqrt(10))
> mean(y)-me
[1] 2.76464
> mean(y)+me
[1] 3.11536
cb)
t.test(y)
One Sample t-test
data: y
t = 27.562, df = 9, p-value = 5.285e-10
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
2.698703 3.181297
sample estimates:
mean of x
2.94
d) In both the cases,the difference between mean and the lower bound and the difference between mean and the upper bound are greater for y than x.
i.e. for y we are getting a larger confidence interval for the mean than x,so for x with larger sample size,it is possible to get more accurate confidence limits for the mean.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.