* This SPSS Syntax generates a set of data which have been drawn from * populations having a specified set of means and variances, and the pattern of * correlations specified in "Compute R = { }. * You can alter this program in a large number of ways to produce whatever data * you wish. For example, you can leave out the material on the pattern of intercorrelations, * and you will have a set of data that are independent (in the population). If the data must be * absolutely independent, leave in the correlation material, but set the correlations to 0.00. * If you want to draw from non-normal populations, simply replace the COMPUTE response = rv.normal(0,1). * command with the command for a different distribution--e.g. "rv.chisq(df)." * If you want to draw variables from a population with a specified mean and variance, use the commands * shown here. For example, Compute violwit = nr1*12.48+20.36. is really just "Compute violwit = * nr1*NewSD + NewMean." If you want to be sure that the new mean and standard deviation are exactly * 20.36 and 12.48, respectively, then invoke the Statistics/Summarize/Descriptives command with * the "Save standardized values as variables" command, and then apply the transformation to the * standardized variables. * If you run a Principal Components analysis * and extract all factors, and enter these factors in the * Matrix statements (in place of r1, r2, ...), the output variables * will have EXACTLY the pattern of correlations given in R. * David C. Howell * The Factor commands were supplied by Lawrence Gordon. * 4/27/98 new file. input program. * Draw 226 cases. SET SEED random. loop #i = 1 to 226. *Draw data for 7 variables. do repeat response = r1 to r7. COMPUTE response = rv.normal(0,1). end repeat. end case. end loop. end file. end input program. *Modify the next line for your own system. Save outfile = "DataOut.sav". * You now have 7 variables with 226 cases each, drawn from a normal population * with mean = 0 and variance = 1. If you don't care about the correlations among * the variables, skip the next two sections. * The next commands provide a principal components analysis and * give orthogonal factors which will then reproduce the matrix exactly. If you only * want the population to have a specified pattern, skip this section. *You will have to modify in 3 places to adjust to the number of variables. Factor /variables r1 to r7 /analysis r1 to r7 /print correlation extraction /criteria Factors(7) Iterate(25) /extraction pc /rotation norotate /save reg(all). Save outfile = "DataOut.sav". * This section sets the pattern of correlations. Be very very careful here. I invariably * get something wrong and the program aborts. The matrix must be perfectly symmetric. Matrix. Get X /File = "DataOut.sav" /Variables = fac1_1 to fac7_1. Compute R = {1.0, .54, .46, .36, .20, .20, -.11; .54, 1.0, .31, .33, .15, .15, -.15; .46, .31, 1.0, .22, .43, .28, -.08; .36, .33, .22, 1.0, .19, .16, -.15; .20, .15, .43, .19, 1.0, .35, -.18; .20, .15, .28, .16, .35, 1.0, -.20; -.11, -.15, -.08, -.15, -.18, -.20, 1.0}. Compute NewX = X*chol(R). Save NewX /outfile = */variables = nr1 to nr7. End matrix. * Now you have your correlated variables. The next lines adjust the means and variances. RECODE nr5 (-10 thru 0=1) (.0001 thru 10=2) . CORRELATIONS /VARIABLES=nr1 to nr7 /PRINT=TWOTAIL SIG. EXECUTE .