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 of the distributions below, generate a random sample of
size 100 and then plot the normal
probability plot (based on manual algorithm instead of built in
function) of each data and discuss.
(a) t-distribution (df=1)
(b) t-distribution (df=10)
(c) t-distribution (df=100)
(d) standard normal distribution
3. Conduct the exercise 7.33 by R. Also, when you verify the
normality assumption in part (b) of 7.33,
1) The R code generte 1000 random samples of size
from the normal distribution with mean µ = 3 and
standard deviation σ = 2 is given below. The 95% confidence
interval is found as
, where is sample mean and is sample standard deviation.
set.seed(1234)
N <- 1000
n <- 40
mu <- 3
sigma <- 2
p <- 0
for (i in 1:N)
{
X <- rnorm(n,mean =mu, sd =sigma)
X_bar <- mean(X)
X_sd <- sd(X)
if (X_bar - 1.96*X_sd/sqrt(n)< mu & mu < X_bar +
1.96*X_sd/sqrt(n))
{
p <- p+1/N
}
}
p
The output is:
> p
[1] 0.94
We see that the rate of confidence interval contains the true mean is 94% which ios close to theoretical 95%.
We are required to solve only one question. Please post the remaining questions as another post.
Get Answers For Free
Most questions answered within 1 hours.