%Sellke-Bayarri-Berger
clear all
close all
  disp('SBB Calibration')
  lw =2.5; 
  set(0, 'DefaultAxesFontSize', 16);
  fs = 15;
  msize = 10;


sbb = @(p)  - exp(1) * p .* log(p);
alph = @(p) 1./(1 + 1./(-exp(1)*p.*log(p)) );

pp = 0.0001:0.001:0.15 

figure(1)
plot(pp, pp, ':', 'linewidth',lw)
hold on
plot(pp, sbb(pp), 'r-','linewidth',lw)
plot(pp, alph(pp), '-','linewidth',lw)

plot(0.05,0.0, 'o',  'LineWidth',2, 'MarkerEdgeColor','k',...
                'MarkerFaceColor','r',...
                'MarkerSize',10)
plot(0.05,0.05, 'o',  'LineWidth',2, 'MarkerEdgeColor','b',...
                'MarkerFaceColor','y',...
                'MarkerSize',10)
plot(0.05,sbb(0.05),  'o',  'LineWidth', 2, 'MarkerEdgeColor','r',...
                'MarkerFaceColor','y',...
                'MarkerSize',10)
plot(0.05,alph(0.05), 'o',  'LineWidth',2, 'MarkerEdgeColor','b',...
                'MarkerFaceColor','y',...
                'MarkerSize',10)
axis([0 0.15 0 0.7])
legend('Classical {\it p}-value','Bayes Factor for H_0',...
    'Posterior Probability H_0','Location','NorthWest')


%print -depsc 'C:\BESTAT\Test\Testeps\BBS.eps'

