Chapter 2: positive predictive value at 3 months gestational latency

We can update our earlier simulation to accomplish this (continuing with the 3-month contingency table):

PN=[0 0]; %simulated number positive and negative results

HCR=[0 0]; FAM=[0 0]; %simulated numbers of hit/CR and FA/Miss results

for n=1:REPS,

PNind=1+(randi(URNall)>URNhm); PN(PNind)=PN(PNind)+1;

if PNind==1,

if randi(URNhm)<=HIT, HCR(1)=HCR(1)+1;

else FAM(2)=FAM(2)+1; end

else

if randi(URNcf)<=CR, HCR(2)=HCR(2)+1;

else FAM(1)=FAM(1)+1; end, end, end

PNpv=HCR./(HCR+FAM)