I have written some R code which produces the limits of confidence intervals as well as the information if each confidence interval covers the true parameter. I'd like to visualize this but have no idea how.
confInt <- function(runs){
result<-NULL
vleft<-NULL
vright<-NULL
for (i in 1:runs) {
data<-rnorm(1000)
n<-length(data)
a<-mean(data)
s<-sd(data)
error <- qnorm(0.975)*s/sqrt(n)
left <- a-error
right <- a+error
result[i] = left<0 & 0<right
vleft[i] = left
vright[i] = right
}
data.frame(result,vleft,vright)
}
confInt(100)
Aucun commentaire:
Enregistrer un commentaire