* For the trial analyses, the program was set to read a raw data file and then process the active SPSS data file -- see the "GET data" command near the start of the program. However, any SPSS system file can be specified on the GET statement; Alternatively, the READ statement (a MATRIX--END MATRIX command) can also be used to read a raw data file. A data matrix can also be entered directly, within the MATRIX--END MATRIX program (see the example further below). * data for the trial analyses -- from Griffin & Gonzalez (1995). data list free / dyad var1 var2 var3. begin 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 end data. descriptives var = all. sort cases by dyad. SET MXLOOP=9000 printback = off width = 132. matrix. * 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 currently active SPSS data file. get data / file = *. * Data can also be entered into the program directly, as in the following example using the "compute data = {" command. * data from Griffin & Gonzalez (1995). compute 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 }. * Remove the above "data" matrix before attempting to process your own data. * Done: The program will can now analyze the data. compute norig = nrow(data). compute tailed = 2. * selecting pairs that have the same dyad #s. compute datarev=make(1,ncol(data),-9999). loop #aa = 1 to nrow(data)-1. do if (data(#aa,1)=data(#aa+1,1)). compute datarev = { datarev ; data(#aa:(#aa+1) ,:) }. end if. end loop. compute data = datarev(2:nrow(datarev),2:ncol(data)). compute n = nrow(data) / 2. * setting up pairwise ("double-counted") collumns of data. compute xp = make(nrow(data),ncol(data),-9999). loop #aa = 1 to nrow(data)/2. compute xp(#aa*2-1,:) = data(#aa*2 ,:). compute xp(#aa*2 ,:) = data(#aa*2-1,:). end loop. compute m = { data , xp }. * correlation matrix. compute nr = nrow(m). compute rawsp = t(m) * m . compute rsums = t(csum(m)). compute corsp = rawsp - (1/nr) * (rsums) * t(rsums) . compute vcv = corsp * (1/(nr-1)). compute d = inv(mdiag(sqrt(diag(vcv)))). compute cr = d * vcv * d. compute overall = cr(1:(nrow(cr)/2) , 1:(ncol(cr)/2)). compute iccross = cr(((nrow(cr)/2)+1):nrow(cr), 1:(nrow(cr)/2)). * significance levels of the intraclass correlations. compute intra = diag(iccross). compute zintra = intra * sqrt(n). compute pzintra = (1 - cdfnorm(abs(zintra))) * tailed. * initializing. compute nstarovr = make(nrow(overall),ncol(overall),-9999). compute zover = nstarovr. compute pzover = nstarovr. compute nstarcrs = nstarovr. compute zcrs = nstarovr. compute pzcrs = nstarovr. compute indcorrs = nstarovr. compute tind = nstarovr. compute ptind = nstarovr. compute dyadcors = nstarovr. compute dstar = nstarovr. compute zdyad = nstarovr. compute pzdyad = nstarovr. compute totcors = nstarovr. loop #ii = 1 to nrow(overall). loop #jj = 1 to ncol(overall). do if (#ii ne #jj). * significance levels of the overall correlations. compute nstarovr(#ii,#jj) = 2 * n / (1+iccross(#ii,#ii)*iccross(#jj,#jj)+iccross(#ii,#jj)**2). compute zover(#ii,#jj) = overall(#ii,#jj)*sqrt(nstarovr(#ii,#jj)). compute pzover(#ii,#jj) = (1-cdfnorm(abs(zover(#ii,#jj))))*tailed. * significance levels of the cross-intraclass correlations. compute nstarcrs(#ii,#jj) = 2*n / (1+iccross(#ii,#ii)*iccross(#jj,#jj)+overall(#ii,#jj)**2). compute zcrs(#ii,#jj) = iccross(#ii,#jj)*sqrt(nstarcrs(#ii,#jj)). compute pzcrs(#ii,#jj) = (1-cdfnorm(abs(zcrs(#ii,#jj))))*tailed. * individual-level correlations. compute indcorrs(#ii,#jj)=(overall(#ii,#jj)-iccross(#ii,#jj))/ (sqrt(1-iccross(#ii,#ii))*sqrt(1-iccross(#jj,#jj))). do if (abs(indcorrs(#ii,#jj)) < 1). compute tind(#ii,#jj) = (indcorrs(#ii,#jj)*sqrt(n-1)) / sqrt(1 - (indcorrs(#ii,#jj)**2)). compute ptind(#ii,#jj)=(1-tcdf(abs(tind(#ii,#jj)),n-1))*tailed. end if. * dyad-level correlations. do if (iccross(#ii,#ii) > 0 and iccross(#jj,#jj) > 0). compute dyadcors(#ii,#jj)=iccross(#ii,#jj)/ (sqrt(iccross(#ii,#ii))*sqrt(iccross(#jj,#jj))). compute dstar(#ii,#jj) = (2*n / (1+iccross(#ii,#ii)* iccross(#jj,#jj)+overall(#ii,#jj)**2)) *iccross(#ii,#ii)*iccross(#jj,#jj). compute zdyad(#ii,#jj)=dyadcors(#ii,#jj)*sqrt(dstar(#ii,#jj)). compute pzdyad(#ii,#jj)=(1-cdfnorm(abs(zdyad(#ii,#jj))))*tailed. end if. * total or mean-level correlations. compute totcors(#ii,#jj) = -9999. do if (iccross(#ii,#ii) ne -1 and iccross(#jj,#jj) ne -1). compute totcors(#ii,#jj)=(overall(#ii,#jj)*iccross(#ii,#jj))/ (sqrt(1+iccross(#ii,#ii))*sqrt(1+iccross(#jj,#jj))). end if. end if. end loop. end loop. * preparing the output matrices. compute overzp = make(1,5,-9999). compute iccroszp = overzp. compute indrzp = make(1,6,-9999). compute dyadrzp = overzp. compute totr = make(1,3,-9999). loop #cc = 1 to ncol(overall)-1. loop #rr = (#cc+1) to nrow(overall). compute overzp={ overzp ; #cc, #rr, overall(#cc,#rr), zover(#cc,#rr), pzover(#cc,#rr) }. compute iccroszp={ iccroszp ; #cc, #rr, iccross(#cc,#rr), zcrs(#cc,#rr), pzcrs(#cc,#rr) }. compute indrzp={ indrzp ; #cc, #rr, indcorrs(#cc,#rr), tind(#cc,#rr), (n-1), ptind(#cc,#rr) }. compute dyadrzp={ dyadrzp ; #cc, #rr, dyadcors(#cc,#rr), zdyad(#cc,#rr), pzdyad(#cc,#rr) }. compute totr={ totr ; #cc, #rr, totcors(#cc,#rr) }. end loop. end loop. compute overzp = overzp(2:nrow(overzp),:). compute iccroszp = iccroszp(2:nrow(iccroszp),:). compute indrzp = indrzp(2:nrow(indrzp),:). compute dyadrzp = dyadrzp(2:nrow(dyadrzp),:). compute totr = totr(2:nrow(totr),:). print /title= "Correlational Analyses of Exchangeable-Case Dyadic Data". print /title= "Griffin & Gonzalez, 1995, Psychological Bulletin, 118, 430-439.". print /title="All Significance Tests Are Two-Tailed". print norig /title="Number of Individual Cases in the Data File:". print nrow(data) /title="Number of Individual Cases That Will be Processed:". print { t(1:nrow(intra)),intra,zintra,pzintra} / format "f9.4" /title="Intraclass Correlations, z-values & p-Levels:" /clabels = "Var.#" "r" "z" "p". print overzp /format "f9.4"/title= "Overall Correlations, z-values & p-Levels:" /clabels = "Var.#" "Var.#" " Correl." "z" "p". print iccroszp /format "f9.4"/title= "Cross-Intraclass Correlations, z-values & p-Levels:" /clabels = "Var.#" "Var.#" " Correl." "z" "p". print indrzp /format "f9.4"/title= "Individual-Level Correlations, t-values & p-Levels:" /clabels = "Var.#" "Var.#" " Correl." "t" "df" "p". print dyadrzp /format "f9.4"/title= "Dyad-Level Correlations, z-values & p-Levels:" /clabels = "Var.#" "Var.#" " Correl." "z" "p". print totr /format "f9.4" /title="Total or Mean-Level Correlations:" /clabels = "Var.#" "Var.#" " Correl.". print /title="-9999 indicates that a value could not be computed.". print /title="The computations sometimes produce dyad-level". print /title="correlations > 1.00 or < -1.00. This is most likely to". print /title="occur when an intraclass correlations is weak.". print /title="See Griffin & Gonzalez, 1995, p. 434-437 for details.". end matrix.