set.seed(12343) par(mfrow=c(1,3)) CIlower_90<-numeric(10000) CIupper_90<-numeric(10000) pvalue_90<-numeric(10000) for(j in 1:10000) { sample<-rnorm(100,10,2) testres1<-t.test(sample,mu=10, conf.level=0.9) CIlower_90[j]<-testres1$conf.int[1] CIupper_90[j]<-testres1$conf.int[2] pvalue_90[j]<-testres1$p.value } testres1$conf.int[1] testres1$conf.int[2] testres1$p.value reject1_90<-pvalue_90<=0.1 table(reject1_90) color<-rep(gray(.7),100) color[reject1_90[1:100]]<-"blue" plot(0, xlim=c(9,11), ylim=c(1,100), ylab="Sample No.", xlab="", main="90% Confidence Interval") abline(v=10, lty=2) for(j in 1:100) { lines(c(CIlower_90[j], CIupper_90[j]), c(j,j), col=color[j], lwd=1) } set.seed(12343) CIlower_95<-numeric(10000) CIupper_95<-numeric(10000) pvalue_95<-numeric(10000) for(j in 1:10000) { sample<-rnorm(100,10,2) testres1<-t.test(sample,mu=10,conf.level=0.95) CIlower_95[j]<-testres1$conf.int[1] CIupper_95[j]<-testres1$conf.int[2] pvalue_95[j]<-testres1$p.value } testres1$conf.int[1] testres1$conf.int[2] testres1$p.value reject1_95<-pvalue_95<=0.05 table(reject1_95) color<-rep(gray(.7),100) color[reject1_95[1:100]]<-"black" plot(0, xlim=c(9,11), ylim=c(1,100), ylab="Sample No.", xlab="", main="95% Confidence Interval") abline(v=10, lty=2) for(j in 1:100) { lines(c(CIlower_95[j], CIupper_95[j]), c(j,j), col=color[j], lwd=1) } set.seed(12343) CIlower_99<-numeric(10000) CIupper_99<-numeric(10000) pvalue_99<-numeric(10000) for(j in 1:10000) { sample<-rnorm(100,10,2) testres3<-t.test(sample,mu=10,conf.level=0.99) CIlower_99[j]<-testres3$conf.int[1] CIupper_99[j]<-testres3$conf.int[2] pvalue_99[j]<-testres3$p.value } testres3$conf.int[1] testres3$conf.int[2] testres3$p.value reject1_99<-pvalue_99<=0.01 table(reject1_99) color<-rep(gray(.7),100) color[reject1_99[1:100]]<-"dark red" plot(0, xlim=c(9,11), ylim=c(1,100), ylab="Sample No.", xlab="", main="99% Confidence Interval") abline(v=10, lty=2) for(j in 1:100) { lines(c(CIlower_99[j], CIupper_99[j]), c(j,j), col=color[j], lwd=1) }