Simulate t-tests of mean differences I would like to simulate t-tests of mean differences. I would like to simulate data based on 


*

*pre-specified (desired) mean difference between the variables and

*desired t value  3) and p-value


Basically with desired mean difference, t-value and desired p-value. Is it possible to simulate the data and if so how to go about it?. (I am working with R)
 A: Yes you can. What you want is a power analysis, which will help you find the parameters necessary to make up some data. 
See the pwr package in R. Use pwr.t.test(). choose 1) how many samples you want and 2) the p-value (alpha) you're shooting for. set power to 0.5. Take note of the effect size (d) returned in the output. 
Next decide on the mean difference you want and divide it by d. That's the standard deviation you want to use when simulating data. 
Then use rnorm() to make up your two data sets using all of these parameters.
Then, if you want one data set for which a t-test gives you a certain p-value, you can iteratively generate data sets (use repeat), use t-tests to compare the difference between them, check the p-value, and save the data sets if they meet your p-value criteria. pseudo-code looks like this:
repeat {
  set1 <- rnorm()
  set2 <- rnorm()
  tt <- t.test(set1, set2)
  pv <- tt$p.value
  if (pv < 0.05 & pv > 0.04) {
    break
  }
}

Then you will have two data sets for which the t-test gives you a p-value < 0.05 and > 0.06. 
Although it looks based on comments like somebody might have a faster solution.
