* --------------------------------------------------------- * Example of polynomial regression using SAS PROC REG * and the Detroit data set. * This program illustrates * (1) the impact of scale on polynomial regression * (2) the use of orthogonal polynomials * --------------------------------------------------------- *; * * SAS source code to input the Detroit Homicide data * see the file detroit for more information *; TITLE Psychology 7291: Example of polynomial regression; TITLE2 using the Detroit Homicide Data; DATA TEMP; SET p7291.Detroit; * * --- create three sets of variables for the polynomial * (1) YEAR, YEARSQ: Raw Years * (2) DYEAR, DYEARSQ: Years measured as 1, 2, 3, ..., 13 * (3) OYEAR, OYEARSQ: Orthogonal coding *; yearsq = year**2; dyear = year - 1960; dyearsq = dyear*dyear; oyear = year - 1967; oyearsq = oyear*oyear; RUN; *; PROC REG CORR; VAR hom year yearsq dyear dyearsq oyear oyearsq; RAW: MODEL hom = year yearsq; RECODE: MODEL hom = dyear dyearsq; ORTHO: MODEL hom = oyear oyearsq; RUN; * * Learning questions and observations: * (1) compare the Rsquares for the three methods * (2) why do the Rsquares have this pattern? * (3) what substantive conclusions would you draw * about the existence of linear and quadratic * effects using the three methods? * (4) examine the correlation matrix for the variables. * Collinearity diagnostics were not requested in this * example, but if they were, which method would give * the most problems and which the least problems? * (5) Is there a "correct" method? *;