A small robustness discussion
What does each chunk of R code do? (Pages 485 and 493-499 of the text discuss robustness of the t statistic.)
x <- matrix(rnorm(4000,mean=0, sd=1),ncol=4)
y <- matrix(rnorm(20000,mean=0,sd=1),ncol=20)
xbar <- apply(x,1,mean)
ybar <- apply(y,1,mean)
sx <- apply(x,1,sd)
sy <- apply(y,1,sd)
sp <- sqrt((3*sx^2 + 19*sy^2)/22)
t.ratio <- (xbar-ybar)/(sp*sqrt(1/4 + 1/20))
sum(t.ratio <= -1.717144)/1000
x <- matrix(rnorm(4000,mean=0, sd=6),ncol=4)
y <- matrix(rnorm(20000,mean=0,sd=1),ncol=20)
xbar <- apply(x,1,mean)
ybar <- apply(y,1,mean)
sx <- apply(x,1,sd)
sy <- apply(y,1,sd)
sp <- sqrt((3*sx^2 + 19*sy^2)/22)
t.ratio <- (xbar-ybar)/(sp*sqrt(1/4 + 1/20))
sum(t.ratio <= -1.717144)/1000
x <- matrix(runif(4000,min=-10,max=10),ncol=4)
y <- matrix(runif(20000,min=-1,max=1),ncol=20)
xbar <- apply(x,1,mean)
ybar <- apply(y,1,mean)
sx <- apply(x,1,sd)
sy <- apply(y,1,sd)
sp <- sqrt((3*sx^2 + 19*sy^2)/22)
t.ratio <- (xbar-ybar)/(sp*sqrt(1/4 + 1/20))
sum(t.ratio <= -1.717144)/1000
x <- matrix(runif(4000,min=-10,max=10),ncol=4)
y <- matrix(runif(4000,min=-1,max=1),ncol=4)
xbar <- apply(x,1,mean)
ybar <- apply(y,1,mean)
sx <- apply(x,1,sd)
sy <- apply(y,1,sd)
sp <- sqrt((3*sx^2 + 3*sy^2)/6)
t.ratio <- (xbar-ybar)/(sp*sqrt(1/4 + 1/4))
sum(t.ratio <= -1.943180)/1000
x <- matrix(runif(20000,min=-10,max=10),ncol=20)
y <- matrix(runif(20000,min=-1,max=1),ncol=20)
xbar <- apply(x,1,mean)
ybar <- apply(y,1,mean)
sx <- apply(x,1,sd)
sy <- apply(y,1,sd)
sp <- sqrt((19*sx^2 + 19*sy^2)/38)
t.ratio <- (xbar-ybar)/(sp*sqrt(1/20 + 1/20))
sum(t.ratio <= -1.685954)/1000