/* EVALPD.G: evaluation of the likelihood and derivatives for the prisoners dilemma game, using nested fixed point algorithm Equilibrium and the derivatives of the probabilities of confessing for players a and b, pa and pb, with respect to the parameters are calculated by dequil.g procedure. Data is entered via the dt matrix. The first 2 columns of this matrix are binary indicators, d_a and d_b, providing the realized decisions of prisoners a and b respectively, with d_a=1 and d_b=1 indicating confession. By John Rust, University of Maryland. November 2005 */ proc (4)=evalpd(dt,dloc,iloc,cloc,q,ll,dll,ls,lle,h,hll); local d_a,d_b,x_a,x_b,p_a,p_b,dfa,dfb,dllc,i; d_a=dt[.,1]; /* decision of prisoner a */ d_b=dt[.,2]; /* decision of prisoner b */ x_a=dt[.,3]; /* observable type of prisoner a */ x_b=dt[.,4]; /* observable type of prisoner b */ qa=q; /* update preference parameters for a */ qb=q; /* update preference parameters for b */ ll=0; dll=zeros(2,1); dllc=zeros(2,1); h=zeros(2,2); hll=h; i=1; do until i > rows(dt); {p_a,p_b,dfa,dfb}=dequil(x_a[i],x_b[i]); ll=ll+d_a[i]*ln(p_a)+(1-d_a[i])*ln((1-p_a))+ d_b[i]*ln(p_b)+(1-d_b[i])*ln((1-p_b)); dllc[1]=d_a[i]*(dfa[1]+dfa[3])/p_a- (1-d_a[i])*(dfa[1]+dfa[3])/(1-p_a)+ d_b[i]*(dfb[1]+dfb[3])/p_b- (1-d_b[i])*(dfb[1]+dfb[3])/(1-p_b); dllc[2]=d_a[i]*(dfa[2]+dfa[4])/p_a- (1-d_a[i])*(dfa[2]+dfa[4])/(1-p_a)+ d_b[i]*(dfb[2]+dfb[4])/p_b- (1-d_b[i])*(dfb[2]+dfb[4])/(1-p_b); dll=dll+dllc; if (ls == 0); h=h+moment(dllc',1); endif; i=i+1; endo; hll=-h; retp(ll,dll,h,hll); endp;