In: Math
ANSWER USING R CODE
Using the dataset 'LakeHuron' which is a built in R dataset describing the level in feet of Lake Huron from 1872- 1972. To assign the values into an ordinary vector,x, we can do the following 'x <- as.vector(LakeHuron)'. From there, we can access the data easily. Assume the values in X are a random sample from a normal population with distribution X. Also assume the X has an unknown mean and unknown standard deviation. With this information in mind, answer the following.
a) The sample mean of x
b) the sample mean of 8X
c) Using this data, create a 97% confidence interval for X using the a t-distribution critical value tstar.
d) Using this data, create a 3 percent level test of H0:mu = 578.9 versus the alternative Ha:mu > 578.9. USing tis information, calculate the value of the z-statistic
e) With the z-statistic, calculate the appropriate p-value.
The code with explanation is given below.
Code is pasted below so that you can copy and run in R Studio
x <- as.vector(LakeHuron)
# a) sample mean of x
mu <- mean(x)
# b) sample mean of 8X
mu2 <- mean(8*x)
# c) 97% confidence interval for X using the a
t-distribution
n <- length(x) #Sample size
se <- sd(x) /sqrt(n) #Standard error of sampole mean
conf <- 0.97 #Confidence level.
alpha <- 1 - conf #Significance level
df <- n - 1 #Degree of freedom
Lower.Conf = mu - se * qt(1 - alpha/2, df)
Upper.Conf = mu + se * qt(1 - alpha/2, df)
#d) H0:mu = 578.9 ; Ha:mu > 578.9
z = (578.9 - mu)/se # Test statistic z
p.value = pnorm(z, lower.tail = FALSE) # P-value
if(p.value < 0.03 ) {
print("We reject H0 and conclude that there is significant evidence
of Ha")
} else {
print("We fail to reject H0 and conclude that there is no
significant evidence of Ha")
}
# e)
# Calculated in line 21
After running the code, I got below output
a) The sample mean of x = 579.0041
b) the sample mean of 8X = 4632.033
c) Using this data, create a 97% confidence interval for X using the a t-distribution critical value tstar.
(578.7108, 579.2974)
d) Using this data, create a 3 percent level test of H0:mu = 578.9 versus the alternative Ha:mu > 578.9. USing tis information, calculate the value of the z-statistic
z = - 0.7815799
We fail to reject H0 and conclude that there is no significant evidence of Ha
e) With the z-statistic, calculate the appropriate p-value.
0.7827692