Skip to content

R code for simulating p-hacking, based on Ryne Sherman's phack function

Notifications You must be signed in to change notification settings

ecsalomon/p-hack-simulation

Repository files navigation

p-hack-simulation

R code for simulating p-hacking, based on Ryne Sherman's phack function

p-hack-return-power.R is my modification (so far) of the original phack function. The modifications change the function in four ways:

  1. Allow for testing two additional decision rules:
  2. Continuing only if the means are in the predicted direction;
  3. Stopping only when p < pcrit has been observed a set number of times, either overall or in a row.
  4. Add an output argument that changes what is returned, either the original output (data frame of study results) or the proportion of studies returning a significant result.
  5. Add a quiet argument that allows running the function without printing summary results.
  6. Quiet the startup message for the psyc package.

p-hack-power.R runs a series of simulations with the following properties:

  • deltas 0 to 1, in increments of .01
  • batch sizes of 5, 15, 30, 50, 75 per cell
  • up to 1, 2, 3, 4, or 5 batches per study
  • pcrit = .05
  • two-tailed t-tests
  • 10,000 studies per combination of delta, batch size, & number of batches

At delta = 0, "power" is actually alpha

About

R code for simulating p-hacking, based on Ryne Sherman's phack function

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages