The question is: Assume we have a population that is normally distributed with µ = 50 and σ^2 = 10. Simulate 100 samples of size n = 1000 from this population and store the samples together in a matrix (one row for each sample). And get the sample mean for each sample as well as the lower and upper bound of a 95% confidence interval for µ. so I wrote this code:
x <- matrix(rnorm(100*1000, mean= 50, sd = sqrt(10)), nrow=100,
ncol=1000)
sample.means <- rowMeans(x)
q<-apply(x, 1, quantile, probs = c(0.025,0.975))
But I don't think it's working because when I count how many of the CI's contain the true mean I get 100? Any help would be appreciated!
Aucun commentaire:
Enregistrer un commentaire