In: Math
Listed below are the weights of a random sample of blue M&Ms (in grams): 0.881 0.863 0.775 0.854 0.810 0.858 0.818 0.768 0.803 0.833 0.742 0.832 0.807 0.841 0.932 (a) Create a vector with these data. Find the mean, standard deviation and number of observations for these data. (b) Draw a histogram and a normal probability plot for these data. Is the assumption of normality valid for these data? (c) Test the claim that the mean weight of all blue M&Ms is greater than 0.82 grams (α = 0.05). Include the null and alternative hypotheses and your conclusion in the context of the data. (e) Create a plot that includes the sampling distribution of your statistic under the null hypothesis, the value of the statistic as a vertical line, and the P-value. R code
(a)
Create the vector using the code -
> x <- c(0.881,0.863,0.775,0.854,0.81,0.858,0.818,0.768,0.803,0.833,0.742,0.832,0.807,0.841,0.932)
Then you can find the mean, standard deviation and count using the 'mean', 'sd' and 'length' function as -
> mean = mean(x)
> standard_deviation = sd(x)
> count = length(x)
Read the output using the vectors as -
> mean
[1] 0.8278
> standard_deviation
[1] 0.04775712
> count
[1] 15
-------------------------------------------
(b)
You can draw the histogram using the following command -
> hist(x)
This will give you the histogram as -
Then you can generate the Q-Q plot using the code -
> qqnorm(x)
> qqline(x)
This would give you following output -
The data almost seems to fit the line except 2 points. These points can be considered as an outlier and we can say that the data is approximately normally distributed. Hence, assumption of normality is valid.
---------------------------------------------------------------------------
(c)
Null Hypothesis - H0 : 0.82
Alternate Hypothesis - H1 : > 0.82
Significance level = = 0.05
Use the following R-code for getting the p-value of test -
> t.test(x, mu=0.82, alternative = "greater")
This should give you following output -
The p-value of test = 0.2686.
As the p-value is greater than the significance level of 0.05, so we fail to reject the null hypothesis and conclude that there is not enough evidence to conclude that the mean weight of blue M&Ms is greater than 0.82 grams.
---------------------------------------------------
(e)
The sampling distribution of the sample mean would be approximately normal given as -
Where =0.82 grams, s = 0.0478 grams and n = 15.
Use the following code to get the required plot -
> y <- seq(0.77,0.87, by = 0.001)
> prob <- c(dnorm(y,0.82,0.01233084))
> plot(y, prob)
> abline(v =0.8278, lty = 3)
This should give you following output -