/* For the trial analyses, the program was set to read a raw data file named and then process this data file within PROC IML -- see the "USE" command near the start of the program. Alternatively, the READ or EDIT statements (PROC IML commands) can also be used to read a data file. */ /* data from Griffin & Gonzalez (1995) */ data datgg2; input dyad 2-3 var1 7-10 var2 16-17 var3 23-24; cards; 4 52.5 20 5 4 43.5 25 3 6 48.5 64 17 6 41.0 44 4 7 33.5 50 2 7 34.5 19 2 12 45.5 38 8 12 64.5 21 10 14 25.0 26 0 14 26.0 20 2 17 10.5 4 1 17 11.5 6 1 19 51.0 35 12 19 51.5 22 6 21 55.0 27 20 21 63.0 21 3 22 36.5 10 3 22 38.5 19 5 23 59.0 27 4 23 38.5 37 2 27 48.0 29 0 27 53.5 11 22 29 45.5 25 6 29 55.0 25 13 30 40.0 6 3 30 36.0 4 0 31 27.0 76 4 31 32.5 37 10 33 44.0 29 5 33 34.0 14 2 34 45.5 64 45 34 67.5 33 13 35 30.0 9 0 35 29.5 14 0 37 0.0 0 0 37 0.0 1 1 40 31.0 13 0 40 50.5 21 3 42 41.5 26 2 42 42.0 27 11 43 33.5 20 9 43 29.0 11 3 45 62.0 25 22 45 57.0 21 9 47 51.0 23 1 47 58.0 22 5 48 1.5 2 0 48 1.5 5 0 ; run; proc means data=datgg2; var dyad var1 var2 var3; run; options nocenter nodate nonumber linesize=100 pagesize=500; title; proc iml; reset noname; /* Correlational Analyses of Exchangeable-Case Dyadic Data Griffin & Gonzalez, 1995, Psychological Bulletin, 118, 430-439. */ /* Create a data matrix where rows = cases, & columns = variables; the first collumn of data must contain the dyad numbers (the dyad id# given to both dyad members); the second and subsequent collumns contain the variables to be analyzed. the data files must have been sorted by dyad id# (e.g., "sort cases by dyad, person"); Cases with missing values are not permitted in the data file; Use the following name for the data matrix: "data" */ /* The following command causes the program to process the SAS data file that was created above. */ use datgg2; read all var _num_ into data; /* Data can also be entered into the program directly, as in the following example using the "data = {" command. */ /* data from Griffin & Gonzalez (1995) */ data = { 4 52.5 20 5, 4 43.5 25 3, 6 48.5 64 17, 6 41.0 44 4, 7 33.5 50 2, 7 34.5 19 2, 12 45.5 38 8, 12 64.5 21 10, 14 25.0 26 0, 14 26.0 20 2, 17 10.5 4 1, 17 11.5 6 1, 19 51.0 35 12, 19 51.5 22 6, 21 55.0 27 20, 21 63.0 21 3, 22 36.5 10 3, 22 38.5 19 5, 23 59.0 27 4, 23 38.5 37 2, 27 48.0 29 0, 27 53.5 11 22, 29 45.5 25 6, 29 55.0 25 13, 30 40.0 6 3, 30 36.0 4 0, 31 27.0 76 4, 31 32.5 37 10, 33 44.0 29 5, 33 34.0 14 2, 34 45.5 64 45, 34 67.5 33 13, 35 30.0 9 0, 35 29.5 14 0, 37 0.0 0 0, 37 0.0 1 1, 40 31.0 13 0, 40 50.5 21 3, 42 41.5 26 2, 42 42.0 27 11, 43 33.5 20 9, 43 29.0 11 3, 45 62.0 25 22, 45 57.0 21 9, 47 51.0 23 1, 47 58.0 22 5, 48 1.5 2 0, 48 1.5 5 0 }; norig = nrow(data); tailed = 2; /* collumn sums module */ start csum(matname); csums =j(1,ncol(matname)); do cols = 1 to ncol(matname); dumc = matname[,cols]; csums[1,cols]=sum(dumc); end; return(csums); finish; /* correlation matrix module */ start corrcoef(matname); cases = nrow(matname); nm1 = cases - 1; zscores = j(cases, ncol(matname), -999); do loopc = 1 to ncol(matname); mean = sum(matname[,loopc]) / cases; sd = sqrt ( ssq((matname[,loopc]- mean)) / nm1 ); zscores[,loopc] = (matname[,loopc] - mean) / sd; end; rdata = (1 / nm1 ) * ( t(zscores) * zscores ); return(rdata); finish; /* selecting pairs that have the same dyad #s */ datarev=j(1,ncol(data),-9999); do aa = 1 to nrow(data)-1; if (data[aa,1]=data[aa+1,1]) then do; datarev = ( datarev // data[aa:(aa+1) ,] ); end; end; data = datarev[2:nrow(datarev),2:ncol(data)]; n = nrow(data) / 2; /* setting up pairwise ("double-counted") collumns of data */ xp = j(nrow(data),ncol(data),-9999); do aa = 1 to nrow(data)/2; xp[aa*2-1,] = data[aa*2 ,]; xp[aa*2 ,] = data[aa*2-1,]; end; m = ( data || xp ); cr = corrcoef(m); overall = cr[1:(nrow(cr)/2) , 1:(ncol(cr)/2)]; iccross = cr[((nrow(cr)/2)+1):nrow(cr), 1:(nrow(cr)/2)]; /* significance levels of the intraclass correlations */ intra = vecdiag(iccross); zintra = intra * sqrt(n); pzintra = (1 - probnorm(abs(zintra))) * tailed; /* initializing */ nstarovr = j(nrow(overall),ncol(overall),-9999); zover = nstarovr; pzover = nstarovr; nstarcrs = nstarovr; zcrs = nstarovr; pzcrs = nstarovr; indcorrs = nstarovr; tind = nstarovr; ptind = nstarovr; dyadcors = nstarovr; dstar = nstarovr; zdyad = nstarovr; pzdyad = nstarovr; totcors = nstarovr; do ii = 1 to nrow(overall); do jj = 1 to ncol(overall); if (ii ^= jj) then do; /* significance levels of the overall correlations */ nstarovr[ii,jj] = (2 * n) / (1+iccross[ii,ii]*iccross[jj,jj]+iccross[ii,jj]**2); zover[ii,jj] = overall[ii,jj]*sqrt(nstarovr[ii,jj]); pzover[ii,jj] = (1 - probnorm(abs(zover[ii,jj])))*tailed; /* significance levels of the cross-intraclass correlations */ nstarcrs[ii,jj] = 2*n / (1+iccross[ii,ii]*iccross[jj,jj]+overall[ii,jj]**2); zcrs[ii,jj] = iccross[ii,jj]*sqrt(nstarcrs[ii,jj]); pzcrs[ii,jj] = (1 - probnorm(abs(zcrs[ii,jj])))*tailed; /* individual-level correlations */ indcorrs[ii,jj]=(overall[ii,jj]-iccross[ii,jj])/ (sqrt(1-iccross[ii,ii])*sqrt(1-iccross[jj,jj])); if (abs(indcorrs[ii,jj]) < 1) then do; tind[ii,jj] = (indcorrs[ii,jj]*sqrt(n-1)) / sqrt(1 - (indcorrs[ii,jj]**2)); ptind[ii,jj] = (1 - probt(abs(tind[ii,jj]),n-1))*tailed; end; /* dyad-level correlations */ if (iccross[ii,ii] > 0 & iccross[jj,jj] > 0) then do; dyadcors[ii,jj]=iccross[ii,jj]/ (sqrt(iccross[ii,ii])*sqrt(iccross[jj,jj])); dstar[ii,jj] = (2*n / (1+iccross[ii,ii]* iccross[jj,jj]+overall[ii,jj]**2)) *iccross[ii,ii]*iccross[jj,jj]; zdyad[ii,jj] = dyadcors[ii,jj]*sqrt(dstar[ii,jj]); pzdyad[ii,jj]=(1 - probnorm(abs(zdyad[ii,jj])))*tailed; end; /* total or mean-level correlations */ totcors[ii,jj] = -9999; if (iccross[ii,ii] ^= -1 & iccross[jj,jj] ^= -1) then do; totcors[ii,jj]=(overall[ii,jj]*iccross[ii,jj])/ (sqrt(1+iccross[ii,ii])*sqrt(1+iccross[jj,jj])); end; end; end; end; /* preparing the output matrices */ overzp = j(1,5,-9999); iccroszp = overzp; indrzp = j(1,6,-9999); dyadrzp = overzp; totr = j(1,3,-9999); do cc = 1 to ncol(overall)-1; do rr = (cc+1) to nrow(overall); overzp=( overzp // (cc || rr || overall[cc,rr] || zover[cc,rr] || pzover[cc,rr] )); iccroszp=( iccroszp // (cc || rr || iccross[cc,rr] || zcrs[cc,rr] || pzcrs[cc,rr] )); indrzp=( indrzp // (cc || rr || indcorrs[cc,rr] || tind[cc,rr] || (n-1) || ptind[cc,rr] )); dyadrzp=( dyadrzp // (cc || rr || dyadcors[cc,rr] || zdyad[cc,rr] || pzdyad[cc,rr] )); totr=( totr // (cc || rr || totcors[cc,rr] )); end; end; overzp = overzp[2:nrow(overzp),]; iccroszp = iccroszp[2:nrow(iccroszp),]; indrzp = indrzp[2:nrow(indrzp),]; dyadrzp = dyadrzp[2:nrow(dyadrzp),]; totr = totr[2:nrow(totr),]; print,"Correlational Analyses of Exchangeable-Case Dyadic Data"; print "Griffin & Gonzalez, 1995, Psychological Bulletin, 118, 430-439."; print "All Significance Tests Are Two-Tailed"; print "Number of Individual Cases in the Data File:",norig; print "Number of Individual Cases That Will be Processed:",(nrow(data)); print "Intraclass Correlations, z-values & p-Levels:"; labels = ("Var.#"||"r"||"z"||"p"); print ( t(1:nrow(intra))||intra||zintra||pzintra) [colname=labels format=9.4]; print "Overall Correlations, z-values & p-Levels:"; labels = ("Var.#"||"Var.#"||" Correl."||"z"||"p"); print overzp [colname=labels format=9.4]; print "Cross-Intraclass Correlations, z-values & p-Levels:"; labels = ("Var.#"||"Var.#"||" Correl."||"z"||"p"); print iccroszp [colname=labels format=9.4]; print "Individual-Level Correlations, t-values & p-Levels:"; labels = ("Var.#"||"Var.#"||" Correl."||"t"||"df"||"p"); print indrzp [colname=labels format=9.4]; print "Dyad-Level Correlations, z-values & p-Levels:"; labels = ("Var.#"||"Var.#"||" Correl."||"z"||"p"); print dyadrzp [colname=labels format=9.4]; print "Total or Mean-Level Correlations:"; labels = ("Var.#"||"Var.#"||" Correl."); print totr [colname=labels format=9.4]; print"-9999 indicates that a value could not be computed."; print"The computations sometimes produce dyad-level"; print"correlations > 1.00 or < -1.00. This is most likely to"; print"occur when an intraclass correlations is weak."; print"See Griffin & Gonzalez, 1995, p. 434-437 for details."; quit;