/* For the trial analyses, the program was set to read the raw data file named "datwaba3", 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. */ /* DETECT Data Set A, from www.LevelsOfAnalysis.com variables: DYAD NEGOT SATIS PERF */ data datwaba3; input DYAD NEGOT SATIS PERF; cards; 1 14 14 32 1 22 28 33 3 13 16 39 3 26 26 39 4 26 22 36 4 16 20 35 6 16 16 26 6 24 22 27 7 23 24 27 7 15 22 26 2 20 23 22 2 13 19 22 5 18 15 20 5 22 23 20 8 21 25 4 8 14 17 3 9 27 24 2 9 14 19 4 10 25 25 18 10 15 17 20 31 14 14 32 31 22 28 33 33 13 16 39 33 26 26 39 34 26 22 36 34 16 20 35 36 16 16 26 36 24 22 27 37 23 24 27 37 15 22 26 32 20 23 22 32 13 19 22 35 18 15 20 35 22 23 20 38 21 25 4 38 14 17 3 39 27 24 2 39 14 19 4 40 25 25 18 40 15 17 20 ; run; proc means data=datwaba3; var DYAD NEGOT SATIS PERF; run; options nocenter nodate nonumber linesize=100 pagesize=500; title; proc iml; reset noname; /* WABA - Moderated Regression Analysis */ /* Sources: Schriesheim (1995) Leadership Quarterly, 6, 1-8; Schriesheim et al (1995) Leadership Quarterly, 6, 111-145; Schriesheim et al (1998) Academy of Management Journal, 41, 298-318. */ /* This WABA program focuses on the interaction between two variables in the prediction of a third. It is a WABA extension of regular moderated multiple regression. All variables must be continuous. */ /* Prepare a raw data matrix for analysis, where rows = cases, & columns = variables; Each row contains the data from a single individual; The values/variables in each row are separated from each other by one or more spaces; Cases with missing values are not permitted in the data file. */ /* The first value in each row (i.e., the first column of values in the data file) must be the individuals' group numbers/codes, which must be integers. The program sorts individuals into groups on the basis of these numbers/codes; Variable scores appear in subsequent columns. */ /* The second value in each row (i.e., the second column of values in the data file) are treated by the program as the Dependent/Outcome variable. */ /* The third value in each row (i.e., the third column of values in the data file) are treated by the program as the Independent/Predictor variable. */ /* The fourth value in each row (i.e., the fourth column of values in the data file) are treated by the program as the Moderator variable (technically also an IDV/predictor). */ /* There is no need to enter product term variables or to enter composite variable scores. The program takes care of these aspects of the analyses internally. */ /* Use the following name for the raw data matrix: "alldata" */ /* The following command causes the program to process the SAS data file that was created above. */ use datwaba3; read all var _num_ into alldata; /* Data can also be entered into the program directly, as in the following example using the "alldata = {" command. */ /* DETECT Data Set A, from www.LevelsOfAnalysis.com variables: DYAD NEGOT SATIS PERF */ alldata = { 1 14 14 32, 1 22 28 33, 3 13 16 39, 3 26 26 39, 4 26 22 36, 4 16 20 35, 6 16 16 26, 6 24 22 27, 7 23 24 27, 7 15 22 26, 2 20 23 22, 2 13 19 22, 5 18 15 20, 5 22 23 20, 8 21 25 4, 8 14 17 3, 9 27 24 2, 9 14 19 4, 10 25 25 18, 10 15 17 20, 31 14 14 32, 31 22 28 33, 33 13 16 39, 33 26 26 39, 34 26 22 36, 34 16 20 35, 36 16 16 26, 36 24 22 27, 37 23 24 27, 37 15 22 26, 32 20 23 22, 32 13 19 22, 35 18 15 20, 35 22 23 20, 38 21 25 4, 38 14 17 3, 39 27 24 2, 39 14 19 4, 40 25 25 18, 40 15 17 20 }; /* Done. The program will can now analyze the data. */ /* 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; /* specifying/creating the data for each set of analyses */ /* creating the IDV/Moderator Composite Variable */ x = ( j(nrow(alldata),1,1) || alldata[,3:4] ); y = alldata[,2]; b = inv(t(x) * x) * t(x) * y; comp = alldata[,3] * b[2,1] + alldata[,4] * b[3,1]; alldata = ( alldata || comp ); /* creating the IDV/Moderator Product Term Composite Variable */ product = alldata[,3]#alldata[,4]; x = ( j(nrow(alldata),1,1) || alldata[,3:4] || product ); y = alldata[,2]; b = inv(t(x) * x) * t(x) * y; comp = alldata[,3] * b[2,1] + alldata[,4] * b[3,1] + product * b[4,1]; data = ( alldata || comp ); /* start of regular WABA analyses */ nss = nrow(data); totmn = csum(data[,2:ncol(data)]) / nss; totdev = j( nss, ncol(data)-1, -9999); withdev = j( nss, ncol(data)-1, -9999); betwdev = j( nss, ncol(data)-1, -9999); grpns = j( 1, 1, -9999); first = 1; ngrps = 0; do luper1 = 2 to nss; if data[(luper1),1] ^= data[(luper1-1),1] | luper1 = nss then do; if luper1 ^= nss then do; last = luper1 - 1; end; if luper1 = nss then do; last = luper1; end; ngrps = ngrps + 1; tempdat = data[first:last,2:ncol(data)]; cmean = csum(tempdat) / nrow(tempdat); grpns = ( grpns // (last - first) + 1 ); do luper2 = first to last; totdev[luper2,] = data[luper2,2:ncol(data)] - totmn; withdev[luper2,] = data[luper2,2:ncol(data)] - cmean; betwdev[luper2,] = cmean - totmn; end; first = luper1; end; end; cormat = corrcoef( ( totdev || betwdev || withdev ) ); nvars = nrow(cormat) / 3; /* mean & sd */ tempdat = data[,2:ncol(data)]; sd = j(1, ncol(tempdat), -9999); mean = csum(tempdat) / nss; do aa = 1 to ncol(tempdat); sd[1,aa] = sqrt(ssq((tempdat[,aa]- mean[1,aa]))/(nss-1)); end; print,"WABA -- Moderated Regression"; print "Number of Individual Cases in the Data File:",nss; print "Number of Groups in the Data File:",ngrps; print "Number of Variables for the Analyses:",nvars; print "All Significance Tests Are Two-Tailed"; print "Variable Means and Standard Deviations"; labels = ("Variable"||"Mean"||"Std Dev"); print ( t(1:nvars) || t(mean) || t(sd) ) [colname=labels format=9.4]; /* Within- and Between-Groups Analysis of Variance */ etabetw = vecdiag( cormat[ (nvars+1):(nvars*2), 1:nvars]); etawith = vecdiag( cormat[ (nvars*2+1):(nvars*3), 1:nvars]); etasq = ( etabetw || etawith )##2; /* E tests */ etests = etabetw / etawith; /* dfs for the F values (Dansereau et al 1984, p. 125, 128, 172) */ dfnumt = j(5,1,(ngrps - 1)); dfdemt = j(5,1,(nss - ngrps)); dfnumc = j(5,1,(nss - ngrps)); dfdemc = j(5,1,(ngrps - 1)); /* adjusting the dfs for the composite variables (Shriesheim 1995 p 11) */ dfdemt[4,1] = dfdemt[4,1] - 1; dfdemt[5,1] = dfdemt[5,1] - 2; dfdemc[4,1] = dfdemc[4,1] - 1; dfdemc[5,1] = dfdemc[5,1] - 2; /* F tests */ ftrad = (etests##2) # (dfdemt / dfnumt); fcrctd = ((etawith /etabetw)##2) # (dfdemc / dfnumc); /* sig levels for F */ pftrad = 1 - probf(ftrad,dfnumt[1,1],dfdemt[1,1]); pfcrctd = 1 - probf(fcrctd,dfnumc[1,1],dfdemc[1,1]); /* for displaying only the appropriate F results */ fetas = ( t(1:nvars) || ftrad || dfnumt || dfdemt || pftrad ); do lupev = 1 to nvars; if etawith[lupev,1] > etabetw[lupev,1] then do; fetas[lupev,2] = fcrctd[lupev,1]; fetas[lupev,3] = dfnumc[lupev,1]; fetas[lupev,4] = dfdemc[lupev,1]; fetas[lupev,5] = pfcrctd[lupev,1]; end; end; /* Within- and Between-Groups Analysis of Covariance Analyses */ rbetw = cormat[ (nvars+1):(nvars*2) , (nvars+1):(nvars*2)]; rwith = cormat[ (nvars*2+1):(nvars*3) , (nvars*2+1):(nvars*3)]; rbw = j(1, 4, -9999); do luper = 2 to 5; rbw = (rbw // (1 || luper || rbetw[1,luper] || rwith[1,luper]) ); end; rbw = rbw[2:nrow(rbw),]; /* A test */ atests=arsin(sqrt(1-(rbw[,4]##2)))-arsin(sqrt(1-(rbw[,3]##2))); /* Z test */ zbw = j(4, 1, -9999); if ngrps > 3 then do; do luper = 1 to 4; if abs(rbw[luper,3]) < 1 & abs(rbw[luper,4]) < 1 then do; zbxy =abs( 0.5* ((log(1+abs(rbw[luper,3]))) - (log(1-abs(rbw[luper,3])))) ); zwxy =abs( 0.5* ((log(1+abs(rbw[luper,4]))) - (log(1-abs(rbw[luper,4])))) ); zbw[luper,1] = (zbxy - zwxy) / sqrt( (1/(nss-ngrps-2))+(1/(ngrps-3)) ); if luper = 3 then do; zbw[luper,1] = (zbxy - zwxy) / sqrt( (1/(nss-ngrps-2))+(1/(ngrps-3-1)) ); end; if luper = 4 then do; zbw[luper,1] = (zbxy - zwxy) / sqrt( (1/(nss-ngrps-2))+(1/(ngrps-3-2)) ); end; end; end; end; pzbw = 1 - probnorm(abs(zbw)) ; /* R test of practical sigificance */ rbig = j(nrow(rbw), 2, -9999); do luper = 1 to nrow(rbw); do lupec = 3 to 4; if abs(rbw[luper,lupec]) < 1 then do; /* rbig formula from Dansereau 1984 p 131 */ rbig[luper,lupec-2] = abs( rbw[luper,lupec] / sqrt ( 1 - rbw[luper,lupec]##2 ) ); /* rbig formula from Yamarino & Markham, 1992 p 170 = slightly diff */ /* compute rbig[luper,lupec-2] = rbw[luper,lupec] / ( ( (1 - (rbw[luper,lupec]##2] )##.6667) ); */ end; end; end; /* t-tests of statistical significance (Yamarino & Markham, 1992 p 170) */ dftb = j(4,1,(ngrps - 2)); dftw = j(4,1,(nss - ngrps - 1)); /* adjusting the dfs for the composite variables (Shriesheim 1995 p 11) */ dftb[3,1] = dftb[3,1] - 1; dftb[4,1] = dftb[4,1] - 2; tb = rbig[,1] # sqrt(dftb); tw = rbig[,2] # sqrt(dftw); ptb = j( nrow(tb), 1, -9999 ); ptw = j( nrow(tw), 1, -9999 ); do luper = 1 to nrow(tb); ptb[luper,1] = (1 - probt(abs(tb[luper,1]),dftb[luper,1])) * 2; ptw[luper,1] = (1 - probt(abs(tw[luper,1]),dftw[luper,1])) * 2; end; /* Within- and Between-Groups Components and Raw (Total) Correlations */ compons = rbw; do luper = 1 to nrow(rbw); compons[luper,3] = etabetw[rbw[luper,1],1] * etabetw[rbw[luper,2],1] * rbw[luper,3]; compons[luper,4] = etawith[rbw[luper,1],1] * etawith[rbw[luper,2],1] * rbw[luper,4]; end; compons = ( compons || (compons[,3] + compons[,4]) ); /* A test of the between vs within components difference */ aradians = arsin(sqrt(1-(compons[,4]##2))) - arsin(sqrt(1-(compons[,3]##2))); /* Z test of the between vs within components difference */ zbwc = j(nrow(compons), 1, -9999); if ngrps > 3 then do; do luper = 1 to nrow(compons); if abs(compons[luper,3]) < 1 & abs(compons[luper,4]) < 1 then do; zbxyc =abs( 0.5* ((log(1+abs(compons[luper,3]))) - (log(1-abs(compons[luper,3])))) ); zwxyc =abs( 0.5* ((log(1+abs(compons[luper,4]))) - (log(1-abs(compons[luper,4])))) ); zbwc[luper,1] = (zbxyc - zwxyc) / sqrt( (1/(nss-ngrps-2))+(1/(ngrps-3)) ); if luper = 3 then do; zbw[luper,1] = (zbxy - zwxy) / sqrt( (1/(nss-ngrps-2))+(1/(ngrps-3-1)) ); end; if luper = 4 then do; zbw[luper,1] = (zbxy - zwxy) / sqrt( (1/(nss-ngrps-2))+(1/(ngrps-3-2)) ); end; end; end; end; pzbwc = (1 - probnorm(abs(zbwc))) * 2; print,"WABA 1 Results -- Dependent Variable:"; labels = ("Eta-Betw"||"Eta-With"||"E Test"||"F"||"df num"||"dfdem"||"p"); print ( etabetw[1,1] || etawith[1,1] || etests[1,1] || fetas[1,2:5] ) [colname=labels format=9.4]; print,"WABA 1 Results -- Independent Variable:"; labels = ("Eta-Betw"||"Eta-With"||"E Test"||"F"||"df num"||"dfdem"||"p"); print ( etabetw[2,1] || etawith[2,1] || etests[2,1] || fetas[2,2:5] ) [colname=labels format=9.4]; print,"WABA 1 Results -- Moderator Variable:"; labels = ("Eta-Betw"||"Eta-With"||"E Test"||"F"||"df num"||"dfdem"||"p"); print ( etabetw[3,1] || etawith[3,1] || etests[3,1] || fetas[3,2:5] ) [colname=labels format=9.4]; print,"WABA 1 Results -- IDV+Moderator Composite Variable:"; labels = ("Eta-Betw"||"Eta-With"||"E Test"||"F"||"df num"||"dfdem"||"p"); print ( etabetw[4,1] || etawith[4,1] || etests[4,1] || fetas[4,2:5] ) [colname=labels format=9.4]; print,"WABA 1 Results -- IDV+Moderator+Product Term Composite Variable:"; labels = ("Eta-Betw"||"Eta-With"||"E Test"||"F"||"df num"||"dfdem"||"p"); print ( etabetw[5,1] || etawith[5,1] || etests[5,1] || fetas[5,2:5] ) [colname=labels format=9.4]; print," E-test practical significance criteria & inductions:"; print " E >= 1.30323 = Wholes - 15; E >= 1.73205 = Wholes - 30;"; print " E <= 0.76733 = Parts - 15; E <= 0.57735 = Parts - 30;"; print,"WABA 2 Results: Independent Variable Predicting the Dependent Variable:"; labels = ("r-Betw"||"r-With"||"A-test"||"Z-test"||"p"); print ( rbw[1,3:4] || atests[1,1] || zbw[1,1] || pzbw[1,1] ) [colname=labels format=9.4]; labels = ("r-Betw"||"R"||"t-test"||"df"||"p"); print ( rbw[1,3] || rbig[1,1] || tb[1,1] || dftb[1,1] || ptb[1,1] ) [colname=labels format=9.4]; labels = ("r-With"||"R"||"t-test"||"df"||"p"); print ( rbw[1,4] || rbig[1,2] || tw[1,1] || dftw[1,1] || ptw[1,1] ) [colname=labels format=9.4]; print,"WABA 2 Results: Moderator Variable Predicting the Dependent Variable:"; labels = ("r-Betw"||"r-With"||"A-test"||"Z-test"||"p"); print ( rbw[2,3:4] || atests[2,1] || zbw[2,1] || pzbw[2,1] ) [colname=labels format=9.4]; labels = ("r-Betw"||"R"||"t-test"||"df"||"p"); print ( rbw[2,3] || rbig[2,1] || tb[2,1] || dftb[2,1] || ptb[2,1] ) [colname=labels format=9.4]; labels = ("r-With"||"R"||"t-test"||"df"||"p"); print ( rbw[2,4] || rbig[2,2] || tw[2,1] || dftw[2,1] || ptw[2,1] ) [colname=labels format=9.4]; print,"WABA 2 Results: IDV+Moderator Composite Variable Predicting the Dependent Variable:"; labels = ("r-Betw"||"r-With"||"A-test"||"Z-test"||"p"); print ( rbw[3,3:4] || atests[3,1] || zbw[3,1] || pzbw[3,1] ) [colname=labels format=9.4]; labels = ("r-Betw"||"R"||"t-test"||"df"||"p"); print ( rbw[3,3] || rbig[3,1] || tb[3,1] || dftb[3,1] || ptb[3,1] ) [colname=labels format=9.4]; labels = ("r-With"||"R"||"t-test"||"df"||"p"); print ( rbw[3,4] || rbig[3,2] || tw[3,1] || dftw[3,1] || ptw[3,1] ) [colname=labels format=9.4]; print,"WABA 2 Results: IDV+Moderator+Product Term Composite Variable Predicting the Dependent Variable:"; labels = ("r-Betw"||"r-With"||"A-test"||"Z-test"||"p"); print ( rbw[4,3:4] || atests[4,1] || zbw[4,1] || pzbw[4,1] ) [colname=labels format=9.4]; labels = ("r-Betw"||"R"||"t-test"||"df"||"p"); print ( rbw[4,3] || rbig[4,1] || tb[4,1] || dftb[4,1] || ptb[4,1] ) [colname=labels format=9.4]; labels = ("r-With"||"R"||"t-test"||"df"||"p"); print ( rbw[4,4] || rbig[4,2] || tw[4,1] || dftw[4,1] || ptw[4,1] ) [colname=labels format=9.4]; print,"A-test practical significance criteria & inductions:"; print " A >= 0.2618 = Wholes - 15; A >= 0.5236 = Wholes - 30;"; print " A <= -0.2618 = Parts - 15; A <= -0.5236 = Parts - 30;"; print "-9999 indicates the Z test could not be computed."; print "R-test practical significance criteria & inductions:"; print " R >= 0.26795 = S - 15; R >= 0.57735 = S - 30;"; print "A value of -9999 indicates the t-test could not be computed."; print,,"Components: Independent Variable Predicting the Dependent Variable:"; labels = ("Betw"||"With"||"A-test"||"Z-test"||"p"); print ( compons[1,3:4] || atests[1,1] || zbw[1,1] || pzbw[1,1] ) [colname=labels format=9.4]; print,"Components: Moderator Variable Predicting the Dependent Variable:"; labels = ("Betw"||"With"||"A-test"||"Z-test"||"p"); print ( compons[2,3:4] || atests[2,1] || zbw[2,1] || pzbw[2,1] ) [colname=labels format=9.4]; print,"Components: IDV+Moderator Composite Variable Predicting the Dependent Variable:"; labels = ("Betw"||"With"||"A-test"||"Z-test"||"p"); print ( compons[3,3:4] || atests[3,1] || zbw[3,1] || pzbw[3,1] ) [colname=labels format=9.4]; print,"Components: IDV+Moderator+Product Term Composite Variable Predicting the Dependent Variable:"; labels = ("Betw"||"With"||"A-test"||"Z-test"||"p"); print ( compons[4,3:4] || atests[4,1] || zbw[4,1] || pzbw[4,1] ) [colname=labels format=9.4]; print,"A-test practical significance criteria & inductions:"; print " A >= 0.2618 = Wholes - 15; A >= 0.5236 = Wholes - 30;"; print " A <= -0.2618 = Parts - 15; A <= -0.5236 = Parts - 30;"; print "-9999 indicates the Z test could not be computed."; print,,"WABA - Moderated Hierarchical Regression Results for the Within Correlations:"; /* Step 2 */ r2idv = rbw[1,4] ##2; r2idvm = rbw[3,4] ##2; Fidvm = (r2idvm-r2idv) / ((1-r2idvm)/(nss-2-1)); dfnmidvm = 2; dfdmidvm = nss - 2 - 1; pidvm = 1 - probf(abs(Fidvm),dfnmidvm,dfdmidvm); print,"Step 2: Increment for the moderator variable, as a main effect, over the IDV"; print " i.e., for the IDV+Moderator Composite Variable over the IDV:"; print " Step 1 Step 2 Increment"; labels = ("r-With"||"r-With"||"rsq ch"||"F"||"df num"||"df dem"||"p"); print ( rbw[1,4] || rbw[3,4] || (r2idvm-r2idv) || Fidvm || dfnmidvm || dfdmidvm || pidvm ) [colname=labels format=9.4]; /* Step 3 */ r2xn = rbw[4,4] ##2; Fxn = (r2xn-r2idvm) / ((1-r2xn)/(nss-3-1)); dfnmxn = 3; dfdmxn = nss - 3 - 1; pxn = 1 - probf(abs(Fidvm),dfnmxn,dfdmxn); print,"Step 3: Increment for the IDV+Moderator+Product Term Composite Variable over"; print " the two main effects (i.e., over the IDV+Moderator Composite Variable):"; print " Step 1 Step 2 Increment"; labels = ("r-With"||"r-With"||"rsq ch"||"F"||"df num"||"df dem"||"p"); print ( rbw[3,4] || rbw[4,4] || (r2xn-r2idvm) || Fxn || dfnmxn || dfdmxn || pxn ) [colname=labels format=9.4]; print,"WABA - Moderated Hierarchical Regression Results for the Between Correlations:"; /* Step 2 */ r2idv = rbw[1,3] ##2; r2idvm = rbw[3,3] ##2; Fidvm = (r2idvm-r2idv) / ((1-r2idvm)/(ngrps-2-1)); dfnmidvm = 2; dfdmidvm = ngrps - 2 - 1; pidvm = 1 - probf(abs(Fidvm),dfnmidvm,dfdmidvm); print "Step 2: Increment for the moderator variable, as a main effect, over the IDV"; print " i.e., for the IDV+Moderator Composite Variable over the IDV:"; labels = ("r-Betw"||"Betw"||"rsq ch"||"F"||"df num"||"df dem"||"p"); print " Step 1 Step 2 Increment"; print ( rbw[1,3] || (rbw[3,3] || (r2idvm-r2idv) || Fidvm || dfnmidvm || dfdmidvm || pidvm)) [colname=labels format=9.4]; /* Step 3 */ r2xn = rbw[4,3] ##2; Fxn = (r2xn-r2idvm) / ((1-r2xn)/(ngrps-3-1)); dfnmxn = 3; dfdmxn = ngrps - 3 - 1; pxn = 1 - probf(abs(Fidvm),dfnmxn,dfdmxn); print,"Step 3: Increment for the IDV+Moderator+Product Term Composite Variable over"; print " the two main effects (i.e., over the IDV+Moderator Composite Variable):"; print " Step 1 Step 2 Increment"; labels = ("r-Betw"||"Betw"||"rsq ch"||"F"||"df num"||"df dem"||"p"); print ( rbw[3,3] || rbw[4,3] || (r2xn-r2idvm) || Fxn || dfnmxn || dfdmxn || pxn) [colname=labels format=9.4]; quit;