r - Obtain 1000 confidence interval from t.test -
x <- c(1:100) y <- c(89:300) s1 <- sample(x, 30) s2 <- sample(y, 30) mytest <- t.test(s1, s2) mytest$conf.int i run 1000 times , create matrix 1000 intervals obtained. have tried loops every time getting same 1000 intervals. however, every time should give me different interval since sampling each time before performing t.test.
you can replicate:
x <- c(1:100) y <- c(89:300) myci = function(x,y) { s1 <- sample(x, 30) s2 <- sample(y, 30) mytest <- t.test(s1, s2) mytest$conf.int } cis = t(replicate(1000, myci(x,y)))
Comments
Post a Comment