Chapter 6: evidence based on a truncated range of possible rate parameters
In the previous example, we demonstrated numerical calculation of the model likelihood when the model allowed the full range of possible rate parameters (i.e., the possible rates spanned the full binomial range, [0,1]). Here we will numerically compute the likelihood for both a model that uses a uniform and one that uses an exponential prior range, both now over only half the binomial range.
%%% prelim
N=40; S=14; thetas=linspace(0,.5,1201); theta2=0.5;
like2=bpdf(S,N,theta2);
EV=nan(1,2);
%%% numerical solution for Fig. 6.6b,upper
pri=2*ones(size(thetas));
like1=trapz(thetas,pri.*bpdf(S,N,thetas));
EV(1)=10*(log10(like1)-log10(like2));
%%% numerical solution for Fig. 6.6b,lower
lambda=-7.187; Tmax=.5;
pri=lambda.*exp(-lambda.*thetas)./(1-exp(-lambda.*Tmax));
like1=trapz(thetas,pri.*bpdf(S,N,thetas));
EV(2)=10*(log10(like1)-log10(like2));
%%% compare the two calculations
EV