### Power

library(pwr)
fun_calculation <- function(n1,n2,sig.level,power,alternative,es){
d <- cohen.ES(test = 't',size = es)\$effect.size
result <- lapply(n1,function(x){pwr.t2n.test(n1 = x,n2 = n2,d = d,sig.level = sig.level,power = power,alternative = alternative)})
result.df <- data.frame(n1,ceiling(sapply(result,function(x)as.numeric(x[2]))))
colnames(result.df)[2] <- paste0('d=',d,',power=',power,',sig.level=',sig.level,'<br>alternative=',alternative,',Effects size=',es)
return(result.df)
}
n1 <- c(as.vector(sapply(c(10^3,10^4,10^5,10^6,10^7,10^8),function(x)seq(x,by = x,length.out = 9))),10^9)
n2.df <- Reduce(function(x,y){merge(x, y)},lapply(c(0.7,0.8,0.9),function(x)fun_calculation(n1,NULL,0.05,x,'two.sided','small')))
n1:『Number of observations in the first sample』,n2:『Number of observations in the second sample』(Reference manual)
n1 d=0.2,power=0.7,sig.level=0.05
alternative=two.sided,Effects size=small
d=0.2,power=0.8,sig.level=0.05
alternative=two.sided,Effects size=small
d=0.2,power=0.9,sig.level=0.05
alternative=two.sided,Effects size=small
1,000 183 245 357
2,000 168 218 303
3,000 163 211 289
4,000 161 207 282
5,000 160 205 278
6,000 159 203 275
7,000 158 202 274
8,000 158 202 272
9,000 158 201 271
10,000 157 201 270
20,000 156 199 267
30,000 156 198 266
40,000 155 198 265
50,000 155 198 265
60,000 155 197 264
70,000 155 197 264
80,000 155 197 264
90,000 155 197 264
100,000 155 197 264
200,000 155 197 264
300,000 155 197 263
400,000 155 197 263
500,000 155 197 263
600,000 155 197 263
700,000 155 197 263
800,000 155 197 263
900,000 155 197 263
1,000,000 155 197 263
2,000,000 155 197 263
3,000,000 155 197 263
4,000,000 155 197 263
5,000,000 155 197 263
6,000,000 155 197 263
7,000,000 155 197 263
8,000,000 155 197 263
9,000,000 155 197 263
10,000,000 155 197 263
20,000,000 155 197 263
30,000,000 155 197 263
40,000,000 155 197 263
50,000,000 155 197 263
60,000,000 155 197 263
70,000,000 155 197 263
80,000,000 155 197 263
90,000,000 155 197 263
100,000,000 155 197 263
200,000,000 155 197 263
300,000,000 155 197 263
400,000,000 155 197 263
500,000,000 155 197 263
600,000,000 155 197 263
700,000,000 155 197 263
800,000,000 155 197 263
900,000,000 155 197 263
1,000,000,000 155 197 263

### Significance level

n2.df <- Reduce(function(x,y){merge(x, y)},lapply(c(0.1,0.05,0.01),function(x)fun_calculation(n1,NULL,x,0.9,'two.sided','small')))
n1:『Number of observations in the first sample』,n2:『Number of observations in the second sample』(Reference manual)
n1 d=0.2,power=0.9,sig.level=0.1
alternative=two.sided,Effects size=small
d=0.2,power=0.9,sig.level=0.05
alternative=two.sided,Effects size=small
d=0.2,power=0.9,sig.level=0.01
alternative=two.sided,Effects size=small
1,000 273 357 595
2,000 240 303 458
3,000 231 289 426
4,000 227 282 411
5,000 224 278 403
6,000 223 275 397
7,000 221 274 394
8,000 221 272 391
9,000 220 271 389
10,000 219 270 387
20,000 217 267 380
30,000 216 266 377
40,000 216 265 376
50,000 216 265 375
60,000 215 264 375
70,000 215 264 374
80,000 215 264 374
90,000 215 264 374
100,000 215 264 374
200,000 215 264 373
300,000 215 263 373
400,000 215 263 373
500,000 215 263 373
600,000 215 263 373
700,000 215 263 373
800,000 215 263 373
900,000 215 263 373
1,000,000 215 263 373
2,000,000 215 263 373
3,000,000 215 263 373
4,000,000 215 263 373
5,000,000 215 263 373
6,000,000 215 263 373
7,000,000 215 263 373
8,000,000 215 263 373
9,000,000 215 263 373
10,000,000 215 263 372
20,000,000 215 263 372
30,000,000 215 263 372
40,000,000 215 263 372
50,000,000 215 263 372
60,000,000 215 263 372
70,000,000 215 263 372
80,000,000 215 263 372
90,000,000 215 263 372
100,000,000 215 263 372
200,000,000 215 263 372
300,000,000 215 263 372
400,000,000 215 263 372
500,000,000 215 263 372
600,000,000 215 263 372
700,000,000 215 263 372
800,000,000 215 263 372
900,000,000 215 263 372
1,000,000,000 215 263 372

### Conventional effects size

n2.df <- Reduce(function(x,y){merge(x, y)},lapply(c("small","medium","large"),function(x)fun_calculation(n1,NULL,0.05,0.9,'two.sided',x)))
n1:『Number of observations in the first sample』,n2:『Number of observations in the second sample』(Reference manual)
n1 d=0.2,power=0.9,sig.level=0.05
alternative=two.sided,Effects size=small
d=0.5,power=0.9,sig.level=0.05
alternative=two.sided,Effects size=medium
d=0.8,power=0.9,sig.level=0.05
alternative=two.sided,Effects size=large
1,000 357 44 17
2,000 303 43 17
3,000 289 43 17
4,000 282 43 17
5,000 278 43 17
6,000 275 43 17
7,000 274 43 17
8,000 272 43 17
9,000 271 43 17
10,000 270 43 17
20,000 267 43 17
30,000 266 43 17
40,000 265 43 17
50,000 265 43 17
60,000 264 43 17
70,000 264 43 17
80,000 264 43 17
90,000 264 43 17
100,000 264 43 17
200,000 264 43 17
300,000 263 43 17
400,000 263 43 17
500,000 263 43 17
600,000 263 43 17
700,000 263 43 17
800,000 263 43 17
900,000 263 43 17
1,000,000 263 43 17
2,000,000 263 43 17
3,000,000 263 43 17
4,000,000 263 43 17
5,000,000 263 43 17
6,000,000 263 43 17
7,000,000 263 43 17
8,000,000 263 43 17
9,000,000 263 43 17
10,000,000 263 43 17
20,000,000 263 43 17
30,000,000 263 43 17
40,000,000 263 43 17
50,000,000 263 43 17
60,000,000 263 43 17
70,000,000 263 43 17
80,000,000 263 43 17
90,000,000 263 43 17
100,000,000 263 43 17
200,000,000 263 43 17
300,000,000 263 43 17
400,000,000 263 43 17
500,000,000 263 43 17
600,000,000 263 43 17
700,000,000 263 43 17
800,000,000 263 43 17
900,000,000 263 43 17
1,000,000,000 263 43 17