Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. # The most important parameter to vary
  2. sdInEffectSize = 1
  3.  
  4.  
  5. # Other parameters
  6. nbSamples = 5e3
  7. sampleSize = 100
  8. effectSize = 0.2
  9. baseSD = 3
  10. alpha = 0.05
  11.  
  12.  
  13. nbTP = 0
  14. for (i in 1:nbSamples)
  15. {
  16. x1 = rnorm(sampleSize, mean = 0, sd = baseSD)
  17. x2 = x1 + rnorm(sampleSize, mean = effectSize, sd = sdInEffectSize)
  18. if (t.test(x2-x1)$p.value < alpha)
  19. {
  20. nbTP = nbTP + 1
  21. }
  22. }
  23.  
  24. print(nbTP / nbSamples)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement