In: Statistics and Probability
Using R:
The data set “Drink.csv” represents the amount of bio medication
filled in a sample of 50 consecutive 2-liter bottles.
1) At the 0.01 level of significance, can you test whether the mean
amount of medication is different from 2.0 liter using the critical
value approach? What is the absolute value of the critical
points?
2) Can you confirm your conclusion in part a using p value
approach? Can you also replicate p value from t.test using the pt
function?
3) Can you confirm your conclusion in part a using CI approach based on Question 2?
DRINK DATA:
Amount |
2.109 |
2.086 |
2.066 |
2.075 |
2.065 |
2.057 |
2.052 |
2.044 |
2.036 |
2.038 |
2.031 |
2.029 |
2.025 |
2.029 |
2.023 |
2.02 |
2.015 |
2.014 |
2.013 |
2.014 |
2.012 |
2.012 |
2.012 |
2.01 |
2.005 |
2.003 |
1.999 |
1.996 |
1.997 |
1.992 |
1.994 |
1.986 |
1.984 |
1.981 |
1.973 |
1.975 |
1.971 |
1.969 |
1.966 |
1.967 |
1.963 |
1.957 |
1.951 |
1.951 |
1.947 |
1.941 |
1.941 |
1.938 |
1.908 |
1.894 |
Firstly save your data as csv file in excel sheet. Here to call the data in R am using My computers path.
Make sure you choose your own saving path to call the data set.
Let X be the amount of medication. We assume N(µ ,?2) . Where ?2 is unknown.
we want to test H0: µ =2.0 ag H1: µ =! 2.0 at 0.01 level of significance .
We can perform Student t-test for one sample mean.
HERE IS THE
R CODE
data=read.csv("C:\\Users\\HP\\Desktop\\Drink.csv",header=T) #
calling the data set
data
str(data) # seeing the variable in the data set. You will see it as
Amount.(As saved in the excel file)
attach(data) # attaching the data set to work on
t.test(Amount,mu=2.0,conf.level=0.99)
HERE IS THE RESULT
t.test(Amount,mu=2.0,conf.level=0.99)
One Sample t-test
data: Amount
t = 0.11424, df = 49, p-value = 0.9095
alternative hypothesis: true mean is not equal to 2
99 percent confidence interval:
1.98383 2.01761
sample estimates:
mean of x
2.00072
We reject the null hypothesis if obsereved mod t is greater than the critical value.
Here the observed t is 0.11424
and critical value will be the upper 0.005 point of t 49 distn.
WE CAN GET THE CRITICAL POINT BY USING THE CODE
qt(0.995,49)
RESULT IS
2.679952
So here the observed mod t is not greater than the critical value hence there is not enough evidence to suspect the null hypothesis. so we accept the null hypothesis at level of significance 0.01 or at 0.99 confidence level.
And absolute value of the critical point is 2.679952
2) Obviously we can confirm our conclusion using p value approach. If the p value is less than 0.01 we reject the null hypothesis but here the p value is 0.9095 so we fail to reject the null hypothesis and accept it.
For this test the p value is PH0( mod(t)> observed t)=2* P(t49>0.11424)
As the test statistic t follows t distn with 49 df under H0 . And as t is symmetric wrt 0 so 2 is multiplied.
WE CAN GET THE P VALUE USING THE R CODE
2*(1-pt(0.11424,49))
HERE IS THE RESULT
0.9095144
(Which is same as the p value given in the test result)..
3)
we can confirm our conclusion in part a using CI approach based on Question 2..
The interpretation of the Confidence interval given in test result is that with 99% confidence one can say that the true mean will lie within (1.98383 ,2.01761)
So here we wanted to know wheather the true mean is 2.0 or not which is within the interval so definately we accepth that the average ammount is 2.0
Here is the total R code
""
data=read.csv("C:\\Users\\HP\\Desktop\\Drink.csv",header=T) #
calling the data set
data
str(data) # seeing the variable in the data set. You will see it as
Amount.(As saved in the excel file)
attach(data) # attaching the data set to work on
t.test(Amount,mu=2.0,conf.level=0.99)
qt(0.995,49) # getting the critical point of the test
2*(1-pt(0.11424,49)) # getting the p value of the test
""
ANd here is the total output
""
> data=read.csv("C:\\Users\\HP\\Desktop\\Drink.csv",header=T)
# calling the data set
> str(data) # seeing the variable in the data set. You will see
it as Amount.(As saved in the excel file)
'data.frame': 50 obs. of 1 variable:
$ Amount: num 2.11 2.09 2.07 2.08 2.06 ...
> attach(data) # attaching the data set to work on
The following object is masked from data (pos = 3):
Amount
The following object is masked from data (pos = 4):
Amount
>
> t.test(Amount,mu=2.0,conf.level=0.99)
One Sample t-test
data: Amount
t = 0.11424, df = 49, p-value = 0.9095
alternative hypothesis: true mean is not equal to 2
99 percent confidence interval:
1.98383 2.01761
sample estimates:
mean of x
2.00072
>
> qt(0.995,49) # getting the critical point of the test
[1] 2.679952
>
> 2*(1-pt(0.11424,49)) # getting the p value of the test
[1] 0.9095144
>
""
Please help with a thumbs up if you like the answer.