/* This macro computes five measures of reliability (Holsti, Scott's pi, Cohen's */. /* kappa, Krippendorf's alpha, and I-sub-r) when 2 judges are asked to */. /* categorize the same set of units into a set of k categories. The syntax is */. /* AGREE var = judge1 judge2 */. /* where judge1 and judge2 are the names of the variables in the */. /* active SPSS data file corresponding to the judgments of judge1 and 2*/. /* The data file is to be structured so that each object being judged */. /* is represented as a row and the columns represent each judge's */. /* categorization of that object. */. /* The macro does not recognize user missing codes. If a judge failed */. /* to code an object, it should be represented with a period ('.') in the data file */. /* Such objects will be discarded from the analysis */. DEFINE AGREE (var = !cmdend). set mxloop = 1000000. MATRIX. get mat/file = */variables = !var /MISSING = OMIT. compute j1 = mat(:,1). compute j2 = mat(:,2). /* First construct the crosstabulation */. compute j1d = design(j1). compute j2d = design(j2). compute j1e={j1, j1d}. compute j2e={j2, j2d}. compute j5 = {j1;j2}. compute ad=abs(mmin(j5)). compute j5 = j5+ad. compute nnn = make(1,1,999). compute res = {nnn;j5}. loop #i = 2 to nrow(j5). compute ix = res(#i,1). loop #k= #i to 2 by -1. compute k = #k. do if (res(#k-1,1) > ix). compute res(#k,1)=res(#k-1,1). else if (res(#k-1,1) <= ix). BREAK. end if. end loop. compute res(k,1)=ix. end loop. compute res = res(2:nrow(j5),:). compute j5 = res. compute j5d = design(j5). loop i = 1 to nrow(j5d). compute j5d(i,:)=j5d(i,:)*j5(i,1). end loop. compute j6=cmax(j5d). compute mat2=make(ncol(j6),ncol(j6),0). loop i = 1 to nrow(j1). loop k1 = 1 to ncol(j6). do if (j1(i,1)+ad)=j6(1,k1). break. end if. end loop. loop k2 = 1 to ncol(j6). do if (j2(i,1)+ad)=j6(1,k2). break. end if. end loop. compute k3 = {k1, k2}. compute mat2(k1,k2)=mat2(k1,k2)+1. end loop. compute mat = mat2. /* Generate the statistics */. compute rowa = rsum(mat). compute rowb = t(csum(mat)). compute k = ncol(mat). compute rowave = (rowa+rowb)/2. compute n = csum(rowa). compute expk = trace((rowa*t(rowb)/(n*n))). compute exps = trace((rowave*t(rowave)/(n*n))). compute agr = trace(mat). compute holsti = trace(mat)/n. compute pi = (holsti-exps)/(1-exps). compute kappa = (holsti-expk)/(1-expk). do if ((agr/n) >= (1/k)). compute ir = sqrt(((agr/n)-(1/k))*(k/(k-1))). else. compute ir = 0. end if. compute b = rowa+rowb. compute n2 = nrow(rowa). compute x = make(1,n2+1,0). compute k = 0. compute ma = x. loop j = 1 to ((2&**n2)). compute k=k+1. compute x(1,1)=x(1,1)+1. loop i = 1 to n2. do if x(1,i) = 2. compute x(1,i)=0. compute x(1,i+1)=x(1,i+1)+1. end if. end loop. do if (rsum(x) = 2). compute ma={ma;x}. end if. end loop. compute ma = ma(2:nrow(ma),1:(ncol(ma)-1)). loop i = 1 to nrow(ma). compute ma(i,:) = ma(i,:)&*t(b). end loop. compute ma = sscp(ma). compute pm = (csum(rsum(ma))-trace(ma))/2. compute pf = n-agr. compute alpha = 1 - (((2*n)-1)*(pf/pm)). /* print the output */. print/title = "MEASURES OF AGREEMENT AND RELIABILITY IN A CROSSTABULATION". compute j6 = j6-ad. print mat/title = "Table Being Analyzed". print j6/title = "Data Codes Corresponding to Rows and Columns:". compute agre = {holsti; pi; kappa; alpha; ir}. print agre/title = " "/rlabels = "Holsti" "Scott pi" "Kappa" "Alpha" "I-sub-r"/format = F10.4. end matrix. !END DEFINE.