Write a program in (mathrm{R}) that simulates 1000 samples of size (n) from a distribution (F) with
Question:
Write a program in \(\mathrm{R}\) that simulates 1000 samples of size \(n\) from a distribution \(F\) with mean \(\theta\) where \(n, \theta\) and \(F\) are specified below. For each sample compute the observed confidence level that \(\theta\) is in the interval \(\Psi=[-1,1]\) as
\[T_{n-1}\left[n^{1 / 2} \hat{\sigma}_{n}^{-1}\left(\hat{\theta}_{n}+1ight)ight]-T_{n-1}\left[n^{1 / 2} \hat{\sigma}_{n}^{-1}\left(\hat{\theta}_{n}-1ight)ight],\]
where \(\hat{\theta}_{n}\) is the sample mean and \(\hat{\sigma}_{n}\) is the sample standard deviation. Keep track of the average observed confidence level over the 1000 samples.
Repeat the experiment for \(n=5,10,25,50\) and 100 and comment on the results in terms of the consistency of the method.
a. \(F\) is a \(\mathrm{N}(\theta, 1)\) distribution with \(\theta=0.0,0.25, \ldots, 2.0\).
b. \(F\) is a LaPlace \((\theta, 1)\) distribution with \(\theta=0.0,0.25, \ldots, 2.0\).
c. \(F\) is a \(\operatorname{Cauchy}(\theta, 1)\) distribution \(\theta=0.0,0.25, \ldots, 2.0\), where \(\theta\) is taken to be the median (instead of the mean) of the distribution.
Step by Step Answer: