Skip to content

Instantly share code, notes, and snippets.

@vasishth
Created March 9, 2024 06:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vasishth/f313df5b50f8902a4e18e965253178e5 to your computer and use it in GitHub Desktop.
Save vasishth/f313df5b50f8902a4e18e965253178e5 to your computer and use it in GitHub Desktop.
The width of a CI is simply a function of the estimated sd
nsim<-100000
sd_est<-width<-rep(NA,nsim)
for(i in 1:nsim){
y<-rnorm(10)
sd_est[i]<-sd(y)
ci<-t.test(y)$conf.int
width[i]<-ci[2]-ci[1]
}
plot(width,sd_est)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment