1.

Use the seq and/or rep functions to create the following vectors.

vec1 <- seq(3, 99, 3)
vec2 <- rep(seq(1, 3, 1), 33)

2.

Set a seed corresponding to the last four digits of your UCO ID number. Generate a random sample of 33 rolls of a fair six-sided die and store the results in die.roll. Find the mean and standard deviation of die.roll, and construct a histogram of die.roll.

set.seed(0051)
die.roll <- sample(c(1, 2, 3, 4, 5, 6), 33, TRUE)
mean(die.roll)
## [1] 3.757576
sd(die.roll)
## [1] 1.581738
hist(die.roll)

3.

Simulate 10,000 random samples of size 10 from a chi-square distribution with 3 degrees of freedom. Store these samples in a matrix called chisq.data. The mean of the chi square distribution with 3 degrees of freedom is 3. For each sample in chisq.data perform a test of \[ H_0: \mu = 3 \quad vs. \quad H_a: \mu \neq 3 \]
Store the pvalues for each of these tests in a vector called p.values, and compute the type I error rate for this test.

chisq.data <- matrix(rchisq(10000, 3, ncp = 0), nrow = 100, ncol = 100)
t.test(chisq.data[1, ], mu = 3)
## 
##  One Sample t-test
## 
## data:  chisq.data[1, ]
## t = -0.014163, df = 99, p-value = 0.9887
## alternative hypothesis: true mean is not equal to 3
## 95 percent confidence interval:
##  2.535935 3.457488
## sample estimates:
## mean of x 
##  2.996711
t.test <- apply(chisq.data, 1, t.test, mu= 1)
p.values <- sapply(t.test, function(x) x$p.value)

4.

Based on the type I error rate computed in number 3, do you think it is appropriate to perform a t-test for samples of size 10 from a chi-square distribution with 3 degrees of freedom? Briefly explain why or why not. Type your answer below.

Yes, using size 10 from a chi-square distribution with df = 3 was appropriate. I know this because the test proved our null hypothesis true. When a null hypothesis is true, than the test is indeed a Type I Error. Below the mean of x was reported to me as 2.944, very close to our null hypothesis of 3. If our null hypothesis was not true, I would have had a power instead, which means the data parameters are not accurate for the problem.