Skip to content

Instantly share code, notes, and snippets.

@Remi-Gau
Last active February 26, 2019 10:44
Show Gist options
  • Save Remi-Gau/86ad7c9edc88c7acb8fae66024bba70d to your computer and use it in GitHub Desktop.
Save Remi-Gau/86ad7c9edc88c7acb8fae66024bba70d to your computer and use it in GitHub Desktop.
p-hacking "increases power"
% small matlab script to show how p-hacking "increases power" :
% number of false negatives drops as more studies are "p-hacked"
% from Iaonnidis 2005; table 2 ; DOI: 10.1371/journal.pmed.0020124
R = 0.1; % pre-study odds
u = 0:.02:1; % bias : proportion of study that should have given a
% negative but turn out positive (QRPs or other errors).
c = 100; %number of relationship tested
alpha = 0.05;
beta = 0.5;
FN = (1 - u) * c * beta * R / (R + 1);
FP = c * alpha + u * c * (1 - alpha) / (R + 1);
figure(1)
clf
hold on
plot(1:numel(u), FN, 'r')
plot(1:numel(u), FP, 'b')
set(gca, 'xtick', linspace(1, numel(u), 11),...
'xticklabel', linspace(0, 1, 11))
xlabel('bias')
axis([0 numel(u) 0 100])
legend({'false negatives', 'false positives'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment