Question

Question (2) [5 marks] (Use R) Suppose you have a company producing cupcakes. Each cupcake is...

Question (2) [5 marks] (Use R) Suppose you have a company producing cupcakes. Each cupcake is supposed to contain 10 grams of sugar. The cupcakes are produced by a machine that adds the sugar in a bowl before mixing everything. You believe the machine does not add 10 grams of sugar for each cupcake. If your assumption is true, the machine needs to be fixed. You stored the level of sugar of thirty cupcakes. Note: You can create a randomized vector with the function rnorm(). This function generates normally distributed values.

The basic syntax is: rnorm(n, mean, sd) arguments - n: Number of observations to generate - mean: The mean of the distribution. Optional (you can put what you want) - sd: The standard deviation of the distribution.

Optional Note: Why we are using set.seed?. Set the seed of R's random number generator, which is useful for creating simulations or random objects that can be reproduced. The random numbers are the same, and they would continue to be the same no matter how far out in the sequence we went.

a) [1 mark] Generate 30 observations from a Normal distribution with a mean of 9 and a standard deviation of 0.02. Set the seed to 123. Note: Show the R code that you used to generate the dataset and only the first 6 observations from the dataset (output).

b) [1 mark] State the hypothesis to check whether the level of sugar is different than the recipe (You can use either symbols or words).

c) [1 mark] Use a suitable test using R to check your hypothesis in (b), use a significance level (α) of 0.05. Note: Show the R code and the result/output of the hypothesis test.

d) [2 marks] Interpret your finding in (c). Note: State the degree of freedom (0.5 mark), interpret the hypothesis you are testing (interpret statistically and relating to the topic of interest) (1 mark) and interpret the confidence interval (0.5 mark). Note: Interpret the hypothesis statistically means: is it statistically significant or not?

Homework Answers

Answer #1

Que.a

> set.seed(123)
> x=rnorm(30,9,0.02)
> head(x)
[1] 8.988790 8.995396 9.031174 9.001410 9.002586 9.034301

Que.b

Hypothesis:

Que.c

t.test(x,mu=10)

One Sample t-test

data: x
t = -279.42, df = 29, p-value < 2.2e-16
alternative hypothesis: true mean is not equal to 10
95 percent confidence interval:
8.991731 9.006384
sample estimates:
mean of x
8.999058

Que.d

Test statistic, t = -279.42

Degrees of freedom = 29

p value < 2.2e-16

Since p-value is less than 0.05, we reject null hypothesis and conclude that mean sugar content in cupcake is significantly different than 10.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Use the programming language R to code the following project.. * Make sure you turn in...
Use the programming language R to code the following project.. * Make sure you turn in your code and answers from each question. (not the raw data). 1. Generate 1000 random samples of size 40 from the normal distribution with mean µ = 3 and standard deviation σ = 2. Compute 95% the confidence interval of 1000 samples and find the rate of confidence interval contains the true mean. What did you learn from this simulation study? 2. For each...
Instructions: You are not required to use R markdown for the lab assignment. Please include ALL...
Instructions: You are not required to use R markdown for the lab assignment. Please include ALL R commands you used to reach your answers in a word or pdf document. Also, report everything you are asked to do so Problem 2 : Answer the following questions: 1. First run alphas <- seq(0.1, 1, by = 0.1) and nalphas <- - rev(alphas). Based on what you have seen, describe how functions seq and rev work. Then run qnorm(c(nalphas, alphas)) and report...
PLEASE USE R CODE!! Continue to generate standard normal random variables until you have generated n...
PLEASE USE R CODE!! Continue to generate standard normal random variables until you have generated n of them, where n≥100 is such that S/sqrt(n) <0.1, where S is the sample standard deviation of the n data value. (a)How many normals do you think will be generated? (b)What is the sample mean of all the normals generated? (c)What is the sample variance?
Could you please solve these using r code. 1. A pumpkin farmer weighed a simple random...
Could you please solve these using r code. 1. A pumpkin farmer weighed a simple random sample of size n = 20 pumpkins, with these results: 9.6, 8.8, 5.1, 9.7, 9.1, 8.9, 8, 9.2, 2.7, 9.1, 8.5, 7.3, 9.3, 9.6, 4.1, 9.9, 7.6, 9, 7.2, 8.5 (a) Create a QQ plot of the weights. Do you think it is reasonable to assume that the population distribution is normal? Explain your answer. (b) Regardless of your answer to (a), use R...
2) Airline accidents: According to the U.S. National Transportation Safety Board, the number of airline accidents...
2) Airline accidents: According to the U.S. National Transportation Safety Board, the number of airline accidents by year from 1983 to 2006 were 23, 16, 21, 24, 34, 30, 28, 24, 26, 18, 23, 23, 36, 37, 49, 50, 51, 56, 46, 41, 54, 30, 40, and 31. a. For the sample data, compute the mean and its standard error (from the standard deviation), and the median. b. Using R, compute bootstrap estimates of the mean, median and 25% trimmed...
R Code Directions: All work has to be your own, you may not work in groups....
R Code Directions: All work has to be your own, you may not work in groups. Show all work. Submit your solutions in a pdf document on Moodle. Include your R code (which must be commented and properly indented) in the pdf file. Name this pdf file ‘your last name’-HW5.pdf. Also submit one text file with your R code, which must be commented and properly indented. You may only use ‘runif’ to generate random numbers; other random number generating functions...
The Nero Match Company sells matchboxes that are supposed to have an average of 40 matches...
The Nero Match Company sells matchboxes that are supposed to have an average of 40 matches per box, with σ = 10. A random sample of 94 matchboxes shows the average number of matches per box to be 42.9. Using a 1% level of significance, can you say that the average number of matches per box is more than 40? What are we testing in this problem? single proportionsingle mean     What is the level of significance? State the null and...
The Nero Match Company sells matchboxes that are supposed to have an average of 40 matches...
The Nero Match Company sells matchboxes that are supposed to have an average of 40 matches per box, with σ = 7. A random sample of 92 matchboxes shows the average number of matches per box to be 42.7. Using a 1% level of significance, can you say that the average number of matches per box is more than 40? What are we testing in this problem? single mean single proportion (a) What is the level of significance? State the...
This problem requires the use of R-Studio. Consider the mtcars data. In R, you can use...
This problem requires the use of R-Studio. Consider the mtcars data. In R, you can use the following code to get the data: dta <- mtcars Use ?mtcars to read the information about this data set. In what follows, we will fit the regression model: mpgi=β0 + β0vsi+ εi, i=1,2,...,n. Note that, vs is categorical variable, whose value is 1 if the observed car has the V-shaped engine or 0 otherwise. (A) Which of the following is the most accurate...
The Nero Match Company sells matchboxes that are supposed to have an average of 40 matches...
The Nero Match Company sells matchboxes that are supposed to have an average of 40 matches per box, with σ = 8. A random sample of 96 matchboxes shows the average number of matches per box to be 42.5. Using a 1% level of significance, can you say that the average number of matches per box is more than 40? What are we testing in this problem? A.) single mean B.) single proportion      (a) What is the level of significance?...