~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~ Purpose of the macros: to perform automatically all univariate regressions for one, or more, dependent variables and a lot of independent variables. They are useful if you have a lot of predictors, and don't fell like "Copy-Paste" the syntax several times. Marta **************************************************************************** * 'Do All Univariate Regressions' MACROS, for linear and logistic regression ****************************************************************************. * Sample data for both MACROS. INPUT PROGRAM. - VECTOR V(20). - LOOP #I = 1 TO 100. - LOOP #J = 1 TO 20. - COMPUTE V(#J) = NORMAL(1). - END LOOP. - END CASE. - END LOOP. - END FILE. END INPUT PROGRAM. execute. * Let's consider that the first 3 variables are the dependent, * and the last 17 are the independent. * For both MACROS, the dependents' names should be: y1, y2, .... * and the independents': x1, x2, x3..... * So, we are going to RENAME them. RENAME VARIABLES (v1 to v3 = y1 to y3). RENAME VARIABLES (v4 to v20 = x1 to x17). * (the variables must be consecutive in the database * in order to make these two commands work). ********************************************************************. * (1) Linear regression. * MACRO definition. DEFINE lirdoall(!POSITIONAL !TOKENS(1) /!POSITIONAL !TOKENS(1)) DO IF $CASENUM=1. !DO !i=1 !to !1. !LET !yvar=!concat('y', !i). !DO !j=1 !to !2. !LET !xvar=!concat('x', !j). WRITE OUTFILE "c:\\windows\\temp\\alltests.sps" /"REGRESSION" /" /DESCRIPTIVES MEAN STDDEV" /" /STATISTICS COEFF CI R ANOVA" /" /DEPENDENT "!quote(!yvar) /" /METHOD=ENTER " !quote(!xvar) " .". * I have selected some descriptives&statistics, * modify them if needed, but be careful with the / and " . !DOEND. !DOEND. END IF. EXECUTE. INCLUDE FILE="c:\\windows\\temp\\alltests.sps". !ENDDEFINE. * MACRO call: macroname 'number of dependent' 'number of independent'. * The following call will create&run a syntax file that performs * 3x17=51 regressions. SET MPRINT=yes. LIRDOALL 3 17. SET MPRINT=no. ********************************************************************. * (2) Logistic Regression. * MACRO definition. DEFINE lordoall(!POSITIONAL !TOKENS(1) /!POSITIONAL !TOKENS(1)) DO IF $CASENUM=1. !DO !i=1 !to !1. !LET !yvar=!concat('y', !i). !DO !j=1 !to !2. !LET !xvar=!concat('x', !j). WRITE OUTFILE "c:\\windows\\temp\\alltests.sps" /"LOGISTIC REGRESSION VAR="!quote(!yvar) /" /METHOD=ENTER " !quote(!xvar) /" /PRINT=GOODFIT CI(95) .". * I have selected some statistics, * modify them if needed, but be careful with the / and " . !DOEND. !DOEND. END IF. EXECUTE. INCLUDE FILE="c:\\windows\\temp\\alltests.sps". !ENDDEFINE. * First, we need binary dependents for the example. RECODE y1 TO y3 (Lowest thru 0.501=0) (0.501 thru Highest=1) . VALUE LABELS y1 TO y3 0 'No' 1 'Yes'. EXECUTE . * MACRO call: macroname 'number of dependent' 'number of independent'. * The following call will create&run a syntax file that performs * 3x17=51 regressions. LORDOALL 3 17.