Here we create a copy of the table 1.1 of Asymptotic Statistics, A. W. van der Vaart.
Look at the distributions we are working with.
sample.1 <- rnorm(1000, mean = 2, sd = 3)
hist(sample.1)
sample.2 <- rexp(1000, rate = 3)
hist(sample.2)
Generate a collection of data from samples taken.
many.sample.stats <- function(samplefn, samplesize, mu, iterations=1000) {
dat <- Reduce(rbind, lapply(seq(1, iterations),
function(x) {s <- samplefn(samplesize)
data.frame(mean=mean(s),
sd= sd(s))}))
vals <- sqrt(samplesize) * (dat$mean - mu) / dat$sd
vals
}
vals.n <- many.sample.stats(function(ss) {rnorm(ss)}, 1000, 0, 10000)
vals.e <- many.sample.stats(function(ss) {rexp(ss)}, 1000, 1, 10000)
Compute the relevant fraction.
perc.above <- function(bd, ...) {
vals <- many.sample.stats(...)
ct <- length(vals)
ab <- sum(abs(vals) > bd)
ab/ct
}
Get the data
sizes <- c(5,10,15,20,25,50,100)
bd.n.exact <- sapply(sizes,
function(size) 2*(1-pt(1.96, size-1)))
bd.n <- sapply(sizes,
function(size)
perc.above(1.96,
function(ss) {rnorm(ss)},
size,
0,
10000))
bd.e <- sapply(sizes,
function(size)
perc.above(1.96,
function(ss) {rexp(ss)},
size,
1,
10000))
Show the table
library(xtable)
print(xtable(data.frame(bd.n.exact, bd.n, bd.e)), type="html")
| bd.n.exact | bd.n | bd.e | |
|---|---|---|---|
| 1 | 0.12 | 0.12 | 0.18 |
| 2 | 0.08 | 0.08 | 0.13 |
| 3 | 0.07 | 0.07 | 0.11 |
| 4 | 0.06 | 0.07 | 0.09 |
| 5 | 0.06 | 0.06 | 0.09 |
| 6 | 0.06 | 0.06 | 0.07 |
| 7 | 0.05 | 0.06 | 0.06 |