In: Statistics and Probability
in R
To explore the characteristics of a Type I error rate, write the R code to do the following:
(a) Generate 30 values from X~N(μX =10,σX=4) and 30 values from Y~N(μY =10,σY=4). Do not print any of these values. Use a t-test to test the hypotheses given above. (You are allowed to use the built-in R function to perform the t-test.)
(b) Include a comment in your code that identifies the p-value and clearly state the conclusion of the test in part (a). The conclusion is either “Reject H0” or “Do not reject H0”.
(c) Repeat part (a) 4000 times, and retain the p-value for each
of the 4000 tests. Each repetition should generate a new sample for
x and a new sample for y.
Do not print the x values or the y values or the p-values
for any of these tests.
Do not use a loop to perform the repetitions.
(d) Calculate the proportion of the 4000 repetitions in which H0 is rejected. Include a comment in our code that provides the proportion.
(e) Generate a histogram of the 4000 p-values.
(f) Include a comment in your code to answer the question: What probability distribution do the p- values appear to follow?