# permutations and confidence intervals

#### kweb313

##### New Member
Hello!
I am in need of a little guidance on a stat problem...
I've performed a permutation on two data sets, in R, regarding sunblock efficacy, and have concluded that in any permutation, there is only one instance of matching efficacy, the original data set. now I have to find a 95% C.I. for the SPF... do I just use the t.test that I used in the original data t.statistic calculation for my CI?
many thanks!

> n1<-13
> n2<-13
> n<- n1+n2
> data <- ex0430$Control > for (i in 1:n2) { + data[i+n2]<-ex0430$Sunscreen
+ }
> tt <- t.test(data[1:n1], data[(n1+1):n], var.equal=T)
> t_stat <- tt\$statistic
>
>
> B <- 100000; statistics <- numeric(B)
> for (i in 1:B) {
+ idx <- sample(n, n1)
+ d1 <- data[idx]; d2 <- data[-idx]
+ mean1 <- mean(d1); mean2 <- mean(d2)
+ var1 <- var(d1); var2 <- var(d2)
+ sp <- sqrt(((n1-1)*var1+(n2-1)*var2)/(n-2))
+ se <- sp*sqrt(1/n1+1/n2)
+ statistics <- (mean1-mean2)/se
+ }
> sum(t_stat <= statistics) / length(statistics)
 1