Write a program in (mathrm{R}) that generates (b) samples of size (n) from a specified distribution (F)
Question:
Write a program in \(\mathrm{R}\) that generates \(b\) samples of size \(n\) from a specified distribution \(F\) (specified below). For each sample compute the approximate \(100 \alpha \%\) confidence interval for the mean given by \(\left[\bar{X}_{n}-n^{-1 / 2} \sigma z_{(1+\alpha) / 2}, \bar{X}_{n}-ight.\) \(n^{-1 / 2} \sigma z_{(1-\alpha) / 2}\) ] using the known value of the population variance from the distributions specified below. Also compute two additional confidence intervals for the mean where the \(\mathrm{N}(0,1)\) quantiles are replaced by ones based on one- and two-term Cornish-Fisher expansions for \(g_{(1-\alpha) / 2, n}\) and \(g_{(1+\alpha) / 2, n}\). Compute the percentage of time each method for computing the confidence interval contained the true value of the mean over the \(b\) simulated samples. Use \(\alpha=0.10, b=1000\) and repeat the simulation for the sample sizes \(n=5,10,25,50,100,250\), and 500 .
a. \(F\) corresponds to a \(\mathrm{N}(0,1)\) distribution where \(\mu=0, \sigma\) is known to be one, \(ho_{3}=0\) and \(ho_{4}=0\). Note: In this case one needs only to compute the confidence interval for the mean given by the normal approximation.
b. \(F\) corresponds to an Exponential(1) distribution.
c. \(F\) corresponds to a \(\operatorname{Gamma}(2,2)\) distribution.
d. \(F\) corresponds to a \(\operatorname{UnIFORm}(0,1)\) distribution.
Step by Step Answer: