Chapter 6: evidence for the causal mechanism

Here we will compute evidence from simulated perceived eye level and perceived pitch slopes, generated by simulating perceptual settings made while varying the physical pitch of the visual field.

We begin by generating the beta values describing perceptual slopes, and generating noise samples for perceptual settings made under six physical pitch conditions, from -25˚ (top-backward physical pitch) to +25˚ (top-forward physical pitch) in 10˚ increments:

clear; close all

COL=[.55*[1 1 1]; .3 .4 .85; .8 .5 .4];


S=5; N=6; %five sources, six pitch settings per source

thetas=linspace(-25,25,N); sig=1; c=[.6 1.2]; gam=[0 -.6];

Ns=201; slist=linspace(.5,5,Ns); %noise level vector

minP=.5; maxP=1.5; minE=c(2)+gam(2)*maxP; maxE=c(2)+gam(2)*minP;

Nb=201; blist=linspace(minP-.6,maxP+.6,Nb); Ov=ones(Nb,1);

diffs=[diff(blist(1:2)) diff(slist(1:2))];

if ~isnear(mean([minE maxE]),c(1)), error('E-slope range mismatch with known E-slope central value'); end


B1prime=linspace(minP,maxP,S)'; %keep the VP slopes identical across sims

B2c=c+B1prime*gam; %mixing endpoints (independent vs. causal)

Nrat=13; r0=atan(-gam(2)); ratlist=linspace(-.5,1.5,Nrat);

%keep noise samples identical across simulations for clearer comparison

e1=nan(S,N); e2=nan(S,N);

for s=1:S,

e1(s,:)=nrand(0,sig,[1,N]);

e2(s,:)=nrand(0,sig,[1,N]); end

The above can produce the plots of Fig. 6.13c (black and grey), representing data from an independence mechanism and from a causal mechanism, respectively. This plot (Fig 6.13c, upper-left) shows the raw visual pitch (perceptual) data against the raw eye level setting data (this is just all of the data for one perceptual discrimination plotted against the other, with data-pairs matched by source and physical pitch condition), and (Fig. 6.13c, lower-left) the subject-specific slopes leading to those raw data. Notice that while the raw data plot shows a straight-line relation in both the causal and independence models (grey and black, resp.), it is only the causal model slopes that show the theoretically predicted negative straight-line relation.

From here, we take the data from the simulated causal mechanism and compute parameter likelihoods by condition:

Elist=nan(Nrat,2);

for irat=1:Nrat, tic

ratnow=ratlist(irat);

Lall1=zeros(S,Nb,Ns); Lall2=zeros(S,Nb,Ns);

%%%%%%%%R%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% DATA SIM using rotation ratio %%%

B12=rot([B1prime B2c(:,2)],ratnow*r0); %rotation of 2d axes

B1=B12(:,1)+mean([minP maxP])-mean(B12(:,1));

B2=B12(:,2)+mean([minE maxE])-mean(B12(:,2));

d1=e1+B1*thetas;

d2=e2+B2*thetas;

likeFNi=@(phi1,phi2,Sin) [-(N/2)*(mean((phi1-(blist'*thetas)).^2,2)/Sin.^2+mean((Ov*phi2-((c(1)+gam(1)*blist)'*thetas)).^2,2)/Sin.^2)-2*(N+1)*log(Sin)]'; %output is Nb x Nb

likeFNc=@(phi1,phi2,Sin) [-(N/2)*(mean((phi1-(blist'*thetas)).^2,2)/Sin.^2+mean((Ov*phi2-((c(2)+gam(2)*blist)'*thetas)).^2,2)/Sin.^2)-2*(N+1)*log(Sin)]'; %output is Nb x Nb

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% param likelihood by condition %%%

for s=1:S,

d1now=d1(s,:); d2now=d2(s,:);

for is=1:Ns, snow=slist(is);

Lall1(s,:,is)=squeeze(Lall1(s,:,is))+likeFNi(d1now,d2now,snow);

Lall2(s,:,is)=squeeze(Lall2(s,:,is))+likeFNc(d1now,d2now,snow); end, end

%%% [continued below] %%%


From these parameter likelihood values (by model), we would like to verify that our simulation and analysis has captured the raw perceived eye level and perceived pitch vs. physical pitch slopes that underlie our analysis:

%%% [continued from above] %%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% verify source-specific b1, b2 %%%

%%% verify global sigmas %%%

bestlist=nan(S,2); margL=zeros(Ns,2);

for s=1:S,

tmpSdat=squeeze(Lall1(s,:,:));

pb=logsum(tmpSdat,2,diffs(2)); bestlist(s,1)=logpeakval([pb(:) blist(:)]); %independence

ps=logsum(tmpSdat,1,diffs(1)); margL(:,1)=margL(:,1)+ps;

tmpSdat=squeeze(Lall2(s,:,:));

pb=logsum(tmpSdat,2,diffs(2)); bestlist(s,2)=logpeakval([pb(:) blist(:)]); %causality

ps=logsum(tmpSdat,1,diffs(1)); margL(:,2)=margL(:,2)+ps; end

%%% independence model plot

if irat==findnearestN(ratlist,1,1),

figure('Name',['independence model [ratio:' num2str(ratnow) ']']);

subplot(2,2,1); plot([-30 30],[0 0],'k--','LineWidth',1); ylabel('Visual Pitch'); hold on

subplot(2,2,3); plot([-30 30],[0 0],'k--','LineWidth',1); ylabel('Perceived Eye Level'); xlabel('Physical Pitch'); hold on

for s=1:S,

subplot(2,2,1); plot(thetas,d1(s,:),'ko-','MarkerFaceColor','k','MarkerSize',8)

subplot(2,2,3); plot(thetas,d2(s,:),'ko-','MarkerFaceColor','k','MarkerSize',8);

bplot(s,:)=1./[d1(s,:)'\thetas' d2(s,:)'\thetas']; end

subplot(2,2,2); plot(d1(:),d2(:),'ko','MarkerFaceColor','k','MarkerSize',6);

rnow=corrcoef(d1(:),d2(:)); text(-30,17,['corr: r = ' num2str(round(100*rnow(1,2))/100)],'FontName','Arial','FontWeight','bold')

xlabel('Visual Pitch'); ylabel('Perceived Eye Level');

subplot(2,2,4); plotmat(bplot,'ko','MarkerFaceColor','k','MarkerSize',11);

xlabel('Visual Pitch Slope'); ylabel('Perceived Eye Level Slope');

elseif irat==findnearestN(ratlist,0,1),

%%% causality model plot

figure('Name',['causality model [ratio:' num2str(ratnow) ']']);

subplot(2,2,1); plot([-30 30],[0 0],'k--','LineWidth',1); ylabel('Visual Pitch'); hold on

subplot(2,2,3); plot([-30 30],[0 0],'k--','LineWidth',1); ylabel('Perceived Eye Level'); xlabel('Physical Pitch'); hold on

for s=1:S,

subplot(2,2,1); plot(thetas,d1(s,:),'ko-','MarkerFaceColor',.7*[1 1 1],'MarkerSize',8)

subplot(2,2,3); plot(thetas,d2(s,:),'ko-','MarkerFaceColor',.7*[1 1 1],'MarkerSize',8);

bplot(s,:)=1./[d1(s,:)'\thetas' d2(s,:)'\thetas']; end

subplot(2,2,2); plot(d1(:),d2(:),'ko','MarkerFaceColor',.7*[1 1 1],'MarkerSize',6);

rnow=corrcoef(d1(:),d2(:)); text(-30,17,['corr: r = ' num2str(round(100*rnow(1,2))/100)],'FontName','Arial','FontWeight','bold')

xlabel('Visual Pitch'); ylabel('Perceived Eye Level');

subplot(2,2,4); plotmat(bplot,'ko','MarkerFaceColor',.7*[1 1 1],'MarkerSize',11);

xlabel('Visual Pitch Slope'); ylabel('Perceived Eye Level Slope');

end

sest=[logpeakval([margL(:,1) slist(:)]) logpeakval([margL(:,2) slist(:)])];


%%%%%%%%%%%%%%%%%%%%%%%%%

%%% Model likelihoods %%%

for m=1:2, Elist(irat,m)=logsum(margL(:,m),1,diffs(2)); end

Elist(irat,3)=10*(Elist(irat,2)-Elist(irat,1));

disp(''); disp(['iRAT' num2str(irat) ':' toc]); end

Finally, we compute evidence from model likelihoods, and plot both (Fig. 6.13d):

figure(3); clf; hold on

plot(ratlist,Elist(:,3),'ko-','MarkerFaceColor','k','MarkerSize',11);

xlabel('rotation ratio (%rot from causality to independence models)','FontName','Arial','FontSize',15);

ylabel('evidence (db)','FontName','Arial','FontSize',15);

figure(4); clf; hold on

plot(ratlist,Elist(:,1),'ko:','MarkerFaceColor','k'); plot(ratlist,Elist(:,2),'ko:','MarkerFaceColor',COL(1,:))

xlabel('rotation ratio (%rot from causality to independence models)','FontName','Arial','FontSize',15);

ylabel('mod likelihood','FontName','Arial','FontSize',15);