Chapter 6: zero-slope model evidence
Chapter 6: zero-slope model evidence
Evidence for the zero-slope model depends on the orientation of the dataset relative to the horizontal axis.
clear %#ok<*UNRCH>
saveFLAG=0; plotFLAG=1;
COL=[.55*[1 1 1]; .3 .4 .85; .8 .5 .4];
N=6; sig=5; Ns=1201;
slist=linspace(0,101,Ns+1)'; slist=slist(2:end); %noise level
diffs=[diff(slist(1:2))]; thetas=linspace(-100,100,N);
Nrot=11; rotlist=linspace(-pi/12,pi/4+pi/12,Nrot);
%keep noise samples identical across simulations for clearer comparison
eorig=nrand(0,sig,[1 N]);
dorig=[thetas(:) zeros(N,1)];
margL=nan(Nrot,2); sest=zeros(Nrot,2);
for irot=1:Nrot, rotnow=rotlist(irot);
%%%%%%%%R%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% DATA SIM using rotation ratio %%%
dnow=rot(dorig,rotnow);
tnow=dnow(:,1)'; dnow=dnow(:,2)'+eorig;
likeFN0=-(N/2)*(mean( dnow.^2,2)./slist.^2)-(N+1)*log(slist); %output is Ns x 1
likeFN1=-(N/2)*(mean((dnow-tnow).^2,2)./slist.^2)-(N+1)*log(slist); %output is Ns x 1
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% param likelihood by condition %%%
Lall0=likeFN0;
Lall1=likeFN1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% verify global sigma %%%
sest(irot,1)=logpeakval([Lall0 slist]);
sest(irot,2)=logpeakval([Lall1 slist]);
%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Model likelihoods %%%
margL(irot,1)=logsum(Lall0,1,diffs);
margL(irot,2)=logsum(Lall1,1,diffs); end
Elist=10*(margL(:,2)-margL(:,1));
if plotFLAG,
figure(1); clf; hold on
plot(tan(rotlist),Elist,'ko-','MarkerFaceColor','k','MarkerSize',11);
xlabel('data slope','FontName','Arial','FontSize',15);
ylabel('evidence (db)','FontName','Arial','FontSize',15);
if saveFLAG, saveas(figure(1),['slmEvid.pdf']); end
figure(2); clf; hold on;
plot(tan(rotlist),margL(:,1),'ko:','MarkerFaceColor','k');
plot(tan(rotlist),margL(:,2),'ko:','MarkerFaceColor',COL(1,:))
xlabel('data slope','FontName','Arial','FontSize',15);
ylabel('mod likelihood','FontName','Arial','FontSize',15);
if saveFLAG, saveas(figure(30),['slmMLike.pdf']); end, end