* SIMPLE-2way: For interactions between (1) a continuous IDV & a continuous moderator, or (2) a dichotomous IDV & a continuous moderator. **************** START OF TRIAL-RUN DATA ***************************** The following commands generate artificial data that can be used for a trial-run of the program. Just run this whole file. new file. input program. loop #a=1 to 200. compute idv = normal (1). compute mod = normal (1). compute e = normal(1). end case. end loop. end file. end input program. compute dv = 6.7*idv + 2.49*mod + 6.23*(idv* mod) + e*5 . descriptives var = all. * moderated regression on the artificial data. compute x = idv * mod. regression /var= idv mod x dv /statistics=defaults zpp bcov /dependent=dv /enter idv mod /test (x) . **************** END OF TRIAL-RUN DATA ************************************. * This version of the program reads and processes a raw data file, containing the variable scores. (In contrast, the previous version of the program read and processed saved matrix data). * For analyses of your own data, it may be easiest to create the following three variables in your data file: idv, mod, & dv e.g., compute idv = name of the independent variable; e.g., compute mod = name of the moderator variable; e.g., compute dv = name of the dependent variable; There must be no missing values. * The program automatically computes the product term. * The syntax lines below must be run as a group, i.e., run all of the commands between the MATRIX and END MATRIX commands at once, including the MATRIX and END MATRIX commands. set mxloops=999999 printback = off length=none width=100. matrix. * The GET command below reads the data file & creates a data matrix ("datamat"). Enter the name of the dataset (and the file path) on the GET command after "file=". Using a "*" instead of a file name & path causes the program to use the currently active SPSS data set. * Then enter the names of the variables after "variables =" on the GET command. Only three variables names are permitted, and they must appear in the following order: idv, mod, dv. * If the name of the idv in your dataset is something other than "idv", then enter the correct name in the place of "idv" after "variables =". * If the name of the moderator variable in your dataset is something other than "mod", then enter the correct name in the place of "mod" after "variables =". * If the name of the dv in your dataset is something other than "dv", then enter the correct name in the place of "dv" after "variables =". get datamat / file=* / variables = idv, mod, dv / missing=omit. * The program automatically computes the product term. * The program was set to compute simple slope stats for three levels of the moderator: the Mean, one SD below, & one SD above; Alternative low and high levels may be specified now -- simply change the value for multiMOD from "1.0" to whatever multiple of the SD you prefer: e.g., enter "2" for 2 SDs below & above the Mean, e.g., enter "0.5" for .5 of a SD below & above the Mean. compute multiMOD = 1.0 . * Similarly, the program generates data for plots of simple regression lines; The IDV range was set at 2 SDs below and 2 SDs above the IDV mean; Alternative low and high levels may be specified now -- simply change the value for multiIDV from "2.0" to whatever multiple of the SD you prefer. compute multiIDV = 2.0 . * If the IDV is dichotomous, insert "1" in the place of "0" for "dichotom," and insert the coded values (numbers) you used immediately afterwards for "dichotLo" and "dichotHi"; The values do not affect the computations, but the data plot could make more sense to you if you insert the values you used, although the set values of "1" & "2" will do fine . compute dichotom = 0 . compute dichotLo = 1 . compute dichotHi = 2 . ****************** End of User Specifications *********************. * creating the data matrix & product term. compute datam={datamat(:,1:2),(datamat(:,1)&*datamat(:,2)),datamat(:,3)}. * n, mean, sd, & correlation matrix (Bernstein, p. 77-79). compute n = nrow(datam). compute rawsp = t(datam) * datam . compute rsums = t(csum(datam)). compute mn = t(rsums) / n. compute corsp = rawsp - (1/n) * (rsums) * t(rsums) . compute vcv = corsp * (1/(n-1)). compute sd = t(sqrt(diag(vcv))). compute d = inv(mdiag(sqrt(diag(vcv)))). compute cr = d * vcv * d. * Overall regression coeffs. compute beta = inv(cr(1:3,1:3)) * cr(1:3,4) . compute b = (sd(1,4) &/ sd(1,1:3)) &* t(beta) . compute a = mn(1,4) - ( rsum ( mn(1,1:3) &* b ) ) . compute r2all = t(beta) * cr(1:3,4) . compute r2main = t(inv(cr(1:2,1:2))*cr(1:2,4))*cr(1:2,4). compute r2chXn = r2all - r2main. compute fsquared = (r2all - r2main) / (1 - r2all) . compute F = (r2all-r2main) / ((1-r2all)/(n-3-1)). compute dferror = n - 3 - 1. compute pF = 1 - fcdf(F,1,dferror) . print {r2chXn,F,{1},dferror,fsquared,pF}/format="f12.3" /title="Coefficients for the Interaction" / space=2 /clabels="Rsq. ch." "F" "df num." "df denom." "fsquared" "Sig. F". print {t(b),beta}/format="f12.3" /title="Beta weights for the full equation:" /rlabels="idv" "mod" "Xn" /clabels="raw b" "std.beta" . print a /format="f12.3" /title="The intercept is:" . * simple slopes info . compute modlo = mn(1,2) - (sd(1,2) * multiMOD) . compute modmd = mn(1,2). compute modhi = mn(1,2) + (sd(1,2) * multiMOD) . compute slopes={(b(1,1)+(b(1,3)*modlo)) ; (b(1,1)+(b(1,3)*modmd)) ; (b(1,1)+(b(1,3)*modhi)) }. compute aslopes={ (b(1,2)*modlo+a) ; (b(1,2)*modmd+a) ; (b(1,2)*modhi+a) }. compute mse = (n/(n-3))*(sd(1,4)**2)*(1-r2all). compute Sb=mse*inv((mdiag(sd(1,1:3))*cr(1:3,1:3)*mdiag(sd(1,1:3)))*(n-1)). compute SEslopes={ (sqrt ( {1,0,modlo} * Sb * t({1,0,modlo}) )) ; (sqrt ( {1,0,modmd} * Sb * t({1,0,modmd}) )) ; (sqrt ( {1,0,modhi} * Sb * t({1,0,modhi}) )) }. compute tslopes = slopes &/ SEslopes . compute df = { (n-3-1) ; (n-3-1) ; (n-3-1) }. compute zslopes = slopes &* (sd(1,1)/sd(1,4)). compute zSE = SEslopes &* (sd(1,1)/sd(1,4)) . compute dfs = n-3-1 . compute pslopes = (1 - tcdf(abs(tslopes),dfs)) * 2. * df & t values; from Darlington p 516 & Howell 87 p 586; p = 05 two-tailed . compute dft={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,24,26,28, 30,32,34,36,38,40,43,46,49,52,56,60,65,70,75,80,85,90,95,100,110,120,130, 150,175,200,250,300,400,500,600,700,800,900,1000,1000000000; 12.706,4.303,3.182,2.776,2.571,2.447,2.365,2.306,2.262,2.228,2.201,2.179, 2.160,2.145,2.131,2.120,2.110,2.101,2.093,2.086,2.074,2.064,2.056,2.048, 2.042,2.037,2.032,2.028,2.024,2.021,2.017,2.013,2.010,2.007,2.003,2.000, 1.997,1.994,1.992,1.990,1.988,1.987,1.985,1.984,1.982,1.980,1.978,1.976, 1.974,1.972,1.969,1.968,1.966,1.965,1.964,1.963,1.963,1.963,1.962,1.962 }. compute tabledT = 0. loop #a = 1 to 59 . do if (dfs ge dft(1,#a) and dfs < dft(1,#a+1) ). compute tabledT = dft(2,#a) . end if. end loop if (tabledT > 0). compute confidLo = (zslopes - (tabledT &* zSE)) . compute confidHi = (zslopes + (tabledT &* zSE)) . print { aslopes , slopes , tslopes , df , pslopes} /format="f12.3" / space=2 /title= "Simple Slope Coefficients for the DV on the IDV at 3 levels of the Moderator:" /rlabels="Mod=low" "Mod=med" "Mod=high" /clabels="a" "raw b" "t-test" "df" "Sig. T". print { zslopes , zSE , confidLO, confidHI } /format="f12.3" /title="Standardized Simple Slopes & 95% Confidence Intervals: " /rlabels="Mod=low" "Mod=med" "Mod=high" /clabels="std. beta" "SE" "95% Low" "95% Hi". print ((b(1,1)/b(1,3))*-1)/format="f12.3" /title="The simple slope for the DV on the IDV" + " is zero (flat) at Moderator ="/ space=2. print ((b(1,2)/b(1,3))*-1)/format="f12.3" /title="The simple regression lines at " + "Mod=high and Mod=low intersect at IDV =". * data for plot. compute idvlo = mn(1,1) - (sd(1,1) * multiIDV). compute idvhi = mn(1,1) + (sd(1,1) * multiIDV) . compute idv = { idvlo; idvhi; idvlo; idvhi; idvlo; idvhi } . do if (dichotom = 1). compute idv={dichotLO;dichotHi; dichotLO;dichotHi; dichotLO;dichotHi}. end if. compute moder = { modlo;modlo;modmd;modmd;modhi;modhi }. compute dv = (b(1,1)&*idv)+(b(1,2)&*moder)+(b(1,3)&*idv&*moder)+a. compute data = { idv , moder , dv }. print data / space=2/format="f12.3" /title="Data for simple slope plots:" /clabels="IDV" "Mod" "DV" . save data /outfile=* / var=idv mod dv . end matrix. * The following PLOT command can be used instead of the GRAPH command in SPSS version 11 and earlier. * plot vsize=15/hsize=50/ format=contour(3) / plot=dv with idv by mod. graph / line = mean(dv) by idv by mod .