Making simple simulation to confirm power of statistical test? Might seem odd by I'm trying to make a simple simulation to verify some power calculations that I'm finding with the package pwr in R (https://cran.r-project.org/web/packages/pwr/pwr.pdf).
What I did is use the simplest example of a single sample t-test with an N of 25 and a sample of .5:
          pwr.t.test(n = 25,d = .5,type= "one.sample",sig.level = .05)

The results indicated that there should be roughly 67% power in this situation:
One-sample t test power calculation 
          n = 25
          d = 0.5
  sig.level = 0.05
      power = 0.6697077
alternative = two.sided

Then, I made a small simulation where I sampled from a distribution with a mean of 107.5 and a standard deviation of 15 (to get a d=.5) 100,000 times:
                  g <- matrix(NA,nrow = 100000,ncol=1)
                  for(i in 1:100000){
                  x <- rnorm(n = 25,mean = 107.5,sd=15)
                  g[i] = mean(x)}

Finally, I computed the number of times that these samples exceeded the 95% CI of the sampling distribution:
        upper = 100 + (1.96*(15/sqrt(25)))
        lower = 100 - (1.96*(15/sqrt(25)))
        Outcomes <- ifelse((g > upper | g < lower),"Reject Null      Hypothesis","Fail to Reject Null Hypothesis")
        table(Outcomes)/100000

        Outcomes
        Fail to Reject Null Hypothesis         Reject Null Hypothesis 
                   0.29726                        0.70274 

As you can see, there is a small difference (~3%) between the results from the pwr package and my simulation. It seems small but non-trivial. Is there an error somewhere in my logic? 
 A: The test you used in your simulation isn't a t-test because you used 1.96 instead of a t-value and you used the true standard deviation instead of the sample standard deviation. Your simulation was approximating the power of the corresponding "z test":
> pwr.norm.test(d = 0.5, n = 25, power = NULL)

     Mean power calculation for normal distribution with known variance 

              d = 0.5
              n = 25
      sig.level = 0.05
          power = 0.705418
    alternative = two.sided

The following code shows how you can verify the power value given by pwr.t.test.
n <- 25      # sample size
mu <- 107.5  # true mean
sigma <- 15  # true SD
mu0 <- 100   # mean under the null hypothesis

reps <- 100000  # number of simulations

## p-value approach:

pvalues <- numeric(reps)

set.seed(1)

for (i in 1:reps) {
  x <- rnorm(n, mu, sigma)
  t.stat <- (mean(x) - mu0)/(sd(x)/sqrt(n))
  pvalues[i] <- 2*(1 - pt(abs(t.stat), n-1))
  # alternatively: pvalues[i] <- t.test(x, mu = mu0)$p.value
}

> mean(pvalues < 0.05)
[1] 0.66907

## Confidence interval approach:

outsideCI <- numeric(reps) # 1 if mu0 not in 95% CI, otherwise 0

set.seed(2)

for (i in 1:reps) {
  x <- rnorm(n, mu, sigma)
  CI.lower <- mean(x) - qt(0.975, n-1)*sd(x)/sqrt(n)
  CI.upper <- mean(x) + qt(0.975, n-1)*sd(x)/sqrt(n)
  outsideCI[i] <- ifelse(mu0 < CI.lower | mu0 > CI.upper, 1, 0)
}

> mean(outsideCI)
[1] 0.66893

