* 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) (1s & 2s were added in col 2). data list free / dyad person var1 var2 var3. begin data. 4 1 52.5 20 5 4 2 43.5 25 3 6 1 48.5 64 17 6 2 41.0 44 4 7 1 33.5 50 2 7 2 34.5 19 2 12 1 45.5 38 8 12 2 64.5 21 10 14 1 25.0 26 0 14 2 26.0 20 2 17 1 10.5 4 1 17 2 11.5 6 1 19 1 51.0 35 12 19 2 51.5 22 6 21 1 55.0 27 20 21 2 63.0 21 3 22 1 36.5 10 3 22 2 38.5 19 5 23 1 59.0 27 4 23 2 38.5 37 2 27 1 48.0 29 0 27 2 53.5 11 22 29 1 45.5 25 6 29 2 55.0 25 13 30 1 40.0 6 3 30 2 36.0 4 0 31 1 27.0 76 4 31 2 32.5 37 10 33 1 44.0 29 5 33 2 34.0 14 2 34 1 45.5 64 45 34 2 67.5 33 13 35 1 30.0 9 0 35 2 29.5 14 0 37 1 0.0 0 0 37 2 0.0 1 1 40 1 31.0 13 0 40 2 50.5 21 3 42 1 41.5 26 2 42 2 42.0 27 11 43 1 33.5 20 9 43 2 29.0 11 3 45 1 62.0 25 22 45 2 57.0 21 9 47 1 51.0 23 1 47 2 58.0 22 5 48 1 1.5 2 0 48 2 1.5 5 0 end data. descriptives var = all. sort cases by dyad person. SET MXLOOP=9000 printback = off width = 132. matrix. * The Correlational Analysis of Dyad-Level Data in the Distinguishable-Case Gonzalez & Griffin, 1999, Personal Relationships, 6, 449-469. * 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 collumn contains the person id #s (e.g., sex) coded as 1 or 2; the third and subsequent collumns contain the variables to be analyzed. * the data files must have been sorted by dyad id# and by person 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 for the trial analyses -- from Griffin & Gonzalez (1995) (1s & 2s were added in col 2). compute data = { 4, 1, 52.5, 20, 5; 4, 2, 43.5, 25, 3; 6, 1, 48.5, 64, 17; 6, 2, 41.0, 44, 4; 7, 1, 33.5, 50, 2; 7, 2, 34.5, 19, 2; 12, 1, 45.5, 38, 8; 12, 2, 64.5, 21, 10; 14, 1, 25.0, 26, 0; 14, 2, 26.0, 20, 2; 17, 1, 10.5, 4, 1; 17, 2, 11.5, 6, 1; 19, 1, 51.0, 35, 12; 19, 2, 51.5, 22, 6; 21, 1, 55.0, 27, 20; 21, 2, 63.0, 21, 3; 22, 1, 36.5, 10, 3; 22, 2, 38.5, 19, 5; 23, 1, 59.0, 27, 4; 23, 2, 38.5, 37, 2; 27, 1, 48.0, 29, 0; 27, 2, 53.5, 11, 22; 29, 1, 45.5, 25, 6; 29, 2, 55.0, 25, 13; 30, 1, 40.0, 6, 3; 30, 2, 36.0, 4, 0; 31, 1, 27.0, 76, 4; 31, 2, 32.5, 37, 10; 33, 1, 44.0, 29, 5; 33, 2, 34.0, 14, 2; 34, 1, 45.5, 64, 45; 34, 2, 67.5, 33, 13; 35, 1, 30.0, 9, 0; 35, 2, 29.5, 14, 0; 37, 1, 0.0, 0, 0; 37, 2, 0.0, 1, 1; 40, 1, 31.0, 13, 0; 40, 2, 50.5, 21, 3; 42, 1, 41.5, 26, 2; 42, 2, 42.0, 27, 11; 43, 1, 33.5, 20, 9; 43, 2, 29.0, 11, 3; 45, 1, 62.0, 25, 22; 45, 2, 57.0, 21, 9; 47, 1, 51.0, 23, 1; 47, 2, 58.0, 22, 5; 48, 1, 1.5, 2, 0; 48, 2, 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, and where sex=1 & sex=2. compute datarev=make(1,ncol(data),-9999). loop #aa = 1 to nrow(data)-1. do if (data(#aa,1)=data(#aa+1,1) and data(#aa,2)=1 and data(#aa+1,2)=2). 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)-1),-9999). loop #aa = 1 to nrow(data)/2. compute xp(#aa*2-1,:) = data(#aa*2 ,2:ncol(data)). compute xp(#aa*2 ,:) = data(#aa*2-1,2:ncol(data)). 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. * correlations between residuals -- Velicer, 1976. compute c22 = cr(2:nrow(cr),2:ncol(cr)). compute c11 = cr(1,1). compute c12 = cr(1,2:ncol(cr)). compute c22part = c22 - t(c12) * inv(c11) * c12 . compute d = mdiag(1 / (sqrt(diag(c22part)))). compute resd = d * c22part * d . compute overall = resd(1:(nrow(resd)/2), 1:(ncol(resd)/2)). compute iccross=resd(((nrow(resd)/2)+1):nrow(resd),1:(nrow(resd)/2)). * p-Levels of the intraclass correlations. compute intra = diag(iccross). compute zintra = (sqrt(n) * intra) / (1 - intra&**2). compute pzintra = (1 - cdfnorm(abs(zintra))) * tailed. * tests of assumptions involving variances & covariances. * matrix of pairwise ("double-counted") collumns of data for just one sex. compute half = make(1, (ncol(m)-1), -9999). loop #aa = 1 to nrow(m). do if (m(#aa,1) = 1). compute half = { half; m(#aa,(2:ncol(m))) }. end if. end loop. compute half = half(2:nrow(half),:). * variance-covariance matrix & correlation matrix. compute nr2 = nrow(half). compute rawsp2 = t(half) * half . compute rsums2 = t(csum(half)). compute corsp2 = rawsp2 - (1/nr2) * (rsums2) * t(rsums2) . compute vcv2 = corsp2 * (1/(nr2-1)). compute d2 = inv(mdiag(sqrt(diag(vcv2)))). compute cr2 = d2 * vcv2 * d2. compute first = vcv2(1:(nrow(vcv2)/2), 1:(ncol(vcv2)/2)). compute second=vcv2((nrow(vcv2)/2+1):nrow(vcv2),(ncol(vcv2)/2+1):ncol(vcv2)). compute iccross2=cr2(((nrow(cr2)/2)+1):nrow(cr2),1:(nrow(cr2)/2)). compute iccrossv=vcv2(((nrow(vcv2)/2)+1):nrow(vcv2),1:(nrow(vcv2)/2)). * tests for equality of variances. compute vartests = make(nrow(first), 6, -9999). loop #bb = 1 to nrow(first). compute vartests(#bb,1)={ #bb }. compute vartests(#bb,2:3)={ first(#bb,#bb) ,second(#bb,#bb) }. compute vartests(#bb,4)=((first(#bb,#bb)-second(#bb,#bb))*sqrt(nrow(half)-2)) / (2*sqrt(first(#bb,#bb)*second(#bb,#bb)*(1-(iccross2(#bb,#bb)**2)))). compute vartests(#bb,5)=nrow(half)-2. compute vartests(#bb,6)=(1-tcdf(abs(vartests(#bb,4)),vartests(#bb,5)))*tailed. end loop. * tests for equality of the within-category population covariances. compute covarswi = make(1 , 6, -9999). loop #cc = 1 to ncol(first)-1. loop #rr = (#cc+1) to nrow(first). compute line = make(1 , 6, -9999). compute line(1,1:2) = { #cc, #rr }. compute line(1,3:4) = { first(#cc,#rr) , second(#cc,#rr) }. compute line(1,5)=((first(#cc,#rr)-second(#cc,#rr))*sqrt(nrow(half))) / sqrt(first(#cc,#cc)*first(#rr,#rr)+second(#cc,#cc)*second(#rr,#rr)+ 2*(((first(#cc,#rr)+second(#cc,#rr))/2) **2) - 2*(iccrossv(#cc,#cc)*iccrossv(#rr,#rr)+iccrossv(#cc,#rr)*iccrossv(#rr,#cc))). compute line(1,6)=(1 - cdfnorm(abs(line(1,5))))*tailed. compute covarswi = { covarswi ; line }. end loop. end loop. compute covarswi = covarswi(2:nrow(covarswi),:). * tests for equality of the across-category population covariances. compute covarscr = make(1 , 6, -9999). loop #cc = 1 to ncol(first)-1. loop #rr = (#cc+1) to nrow(first). compute line = make(1 , 6, -9999). compute line(1,1:2) = { #cc, #rr }. compute line(1,3:4) = { iccrossv(#cc,#rr) , iccrossv(#rr,#cc) }. compute line(1,5)=((iccrossv(#cc,#rr)-iccrossv(#rr,#cc))*sqrt(nrow(half)))/ sqrt(first(#cc,#cc)*second(#rr,#rr)+second(#cc,#cc)*first(#rr,#rr)+ 2*(((iccrossv(#cc,#rr)+iccrossv(#rr,#cc))/2) **2) - 2*(first(#cc,#rr)*second(#cc,#rr)+iccrossv(#cc,#cc)*iccrossv(#rr,#rr))). compute line(1,6)=(1 - cdfnorm(abs(line(1,5))))*tailed. compute covarscr = { covarscr ; line }. end loop. end loop. compute covarscr = covarscr(2:nrow(covarscr),:). * initializing. compute nstarovr = make(nrow(overall),ncol(overall),-9999). compute zoverwi = nstarovr. compute pzoverwi = nstarovr. compute zovercr = nstarovr. compute pzovercr = nstarovr. compute indcorrs = nstarovr. compute tind = nstarovr. compute ptind = nstarovr. compute dyadcors = nstarovr. compute dstar = nstarovr. compute zdyad = nstarovr. compute pzdyad = nstarovr. loop #ii = 1 to nrow(overall). loop #jj = 1 to ncol(overall). do if (#ii ne #jj). * p-Levels of the overall within-partner correlations. compute nstarovr(#ii,#jj) = (2*n) / (1+iccross(#ii,#ii)*iccross(#jj,#jj)+iccross(#ii,#jj)**2). compute zoverwi(#ii,#jj) = overall(#ii,#jj)*sqrt(nstarovr(#ii,#jj)). compute pzoverwi(#ii,#jj) = (1-cdfnorm(abs(zoverwi(#ii,#jj))))*tailed. * p-Levels of the overall cross-partner correlations. compute zovercr(#ii,#jj) = iccross(#ii,#jj)*sqrt(nstarovr(#ii,#jj)). compute pzovercr(#ii,#jj) = (1-cdfnorm(abs(zovercr(#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-2)) / sqrt(1-(indcorrs(#ii,#jj)**2)). compute ptind(#ii,#jj) = (1 - tcdf(abs(tind(#ii,#jj)),n-2))*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. end if. end loop. end loop. * preparing the output matrices. compute owpart = make(1,5,-9999). compute ocpart = owpart. compute dyadrzp = owpart. compute withrzp = make(1,6,-9999). loop #cc = 1 to ncol(overall)-1. loop #rr = (#cc+1) to nrow(overall). compute owpart={ owpart ; #cc, #rr, overall(#cc,#rr), zoverwi(#cc,#rr), pzoverwi(#cc,#rr) }. compute ocpart={ ocpart ; #cc, #rr, iccross(#cc,#rr), zovercr(#cc,#rr), pzovercr(#cc,#rr) }. compute dyadrzp={ dyadrzp ; #cc, #rr, dyadcors(#cc,#rr), zdyad(#cc,#rr), pzdyad(#cc,#rr) }. compute withrzp={ withrzp ; #cc, #rr, indcorrs(#cc,#rr), tind(#cc,#rr), (n-2), ptind(#cc,#rr) }. end loop. end loop. compute owpart = owpart(2:nrow(owpart),:). compute ocpart = ocpart(2:nrow(ocpart),:). compute dyadrzp = dyadrzp(2:nrow(dyadrzp),:). compute withrzp = withrzp(2:nrow(withrzp),:). print /title="The Correlational Analysis of Dyad-Level Data". print /title="in the Distinguishable-Case". print /title="Gonzalez & Griffin, 1999, Personal Relationships, 6, 449-469.". 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 vcv2 /format "f7.4" /title="Variance-Covariance Matrix for the Primary Variables:". print vartests /format "f9.4" /title="Tests for Equality of Variances:" /clabels="Var.#" "Variance" "Variance" "t" "df" "p". print covarswi /format "f9.4" /title="Tests for Equality of the Within-Person Covariances:" /clabels = "Var.#" "Var.#" "Covar." "Covar." "z" "p". print owpart /format "f9.4"/title= "Overall Within-Partner Correlations, z-values & p-Levels:" /clabels = "Var.#" "Var.#" " r" "z" "p". print covarscr /format "f9.4" /title="Tests for Equality of the Across-Person Covariances:" /clabels = "Var.#" "Var.#" "Covar." "Covar." "z" "p". print ocpart /format "f9.4"/title= "Overall Cross-Partner Correlations, z-values & p-Levels:" /clabels = "Var.#" "Var.#" " r" "z" "p". print { t(1:nrow(intra)),intra,zintra,pzintra} / format "f9.4"/title= "Intraclass Correlations, z-values & p-Levels:" /clabels = "Var.#" "r" "z" "p". print dyadrzp /format "f9.4"/title= "Dyad-Level Correlations, z-values & p-Levels:" /clabels = "Var.#" "Var.#" " r" "z" "p". print withrzp /format "f9.4"/title= "Individual-Level Correlations, t-values & p-Levels:" /clabels = "Var.#" "Var.#" " r" "t" "df" "p". 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.