Plots the intervals

In Exercise 4.2.11, the sampling was from the  distribution. Show, however, that setting μ = 0 and σ = 1 is without loss of generality.

Exercise 4.2.11

Let  be a random sample from a N(0, 1) distribution. Then the probability that the random interval  verify this empirically, in this exercise, we simulate m such intervals and calculate the proportion that trap 0, which should be “close” to (1 − α).

(a) Set n = 10 and m = 50. Run the R code mat=matrix(rnorm(m*n),ncol=n) which generates m samples of size n from the N(0, 1) distribution. Each row of the matrix mat contains a sample. For this matrix of samples, the function below computes the (1 − α)100% confidence intervals, returning them in a m × 2 matrix. Run this function on your generated matrix mat. What is the proportion of successful confidence intervals?


(b) Run the following code which plots the intervals. Label the successful intervals. Comment on the variability of the lengths of the confidence intervals.


Posted in Uncategorized

Leave a Reply