### Confidence Level
mu <- 100
sigma <- 10
Count <- 0
M <- 1000
for(i in 1: M) {
x <- rnorm(30,mu,sigma)
t.out <- t.test(x)
LCB <- t.out$conf.int[1]
UCB <- t.out$conf.int[2]
if(mu > LCB && mu < UCB) Count
<- Count + 1
}
conf.est <- Count/M
conf.est
### Significance Level
mu <- 100
sigma <- 10
mu1 <- 110
Count <- 0
M <- 10000
alpha <- 0.05
for(i in 1: M) {
x <- rnorm(30,mu,sigma)
t.out <- t.test(x, mu = mu)
pvalue <- t.out$p.value
if(pvalue < alpha) Count <- Count + 1
}
alpha.est <- Count/M
alpha.est
|