%% A simple demonstration of an ROC
% This requres CANlab Core tools, and uses the CANlab function roc_plot

% Create 1000 cases where a true effect is either present or absent
true_effect = unifrnd(0, 1, 1000, 1) > 0.5;

% Simulate hypothetical beta-hat 
% t-values are identical in both cases; the test statistic is not informative 
betahat(true_effect == 0) = randn(sum(true_effect == 0), 1);
betahat(true_effect == 1) = randn(sum(true_effect == 1), 1);

create_figure('ROC_badmodel');
ROC = roc_plot(betahat, true_effect, 'color', 'k', 'plothistograms');

title('ROC with an uninformative model')

%

create_figure('ROC_goodmodel');
% Now repeat, but with a true effect size of 2
betahat(true_effect == 1) = 2 + randn(sum(true_effect == 1), 1);

ROC = roc_plot(betahat, true_effect, 'color', 'r', 'plothistograms');
xlabel('Beta');
ylabel('Frequency');
title('Null distribution in green, alternative in blue')

figure(findobj('Tag', 'ROC_goodmodel'))
title('Informative model, true effect = 2 SE')