/*********************************************** SAS EXAMPLE -- CORRELATION MULTIPLE REGRESSION COLLINEARITY DIAGNOSTICS FILENAME: multiple_regression.sas ************************************************/ options formdlim=" " pageno=1; title; libname labdata "d:\510\2007\"; data labdata.werner3; set labdata.werner2; wtalb = wt + alb; run; /*FIRST, EXAMINE CORRELATION MATRIX*/ TITLE "PEARSON CORRELATION MATRIX LISTWISE DELETION"; proc corr data=labdata.werner3 nomiss; var chol age calc uric alb wt wtalb; run; TITLE "PEARSON CORRELATION MATRIX PAIRWISE DELETION"; proc corr data=labdata.werner3 /*nomiss*/ nosimple; var chol age calc uric alb wt wtalb; run; TITLE1 "MULTIPLE REGRESSION ANALYSIS"; TITLE2 "WITH INFLUENCE DIAGNOSTICS"; ods trace on; proc reg data=labdata.werner; model chol = age calc uric alb wt / stb tol vif collin; output out=outreg1 p=predict1 r=resid1 rstudent=rstud1 cookd = cookd1 dffits=dffits; plot rstudent. * predicted.; ods output OutputStatistics = OutputStat1; run;quit; ods trace off; TITLE "DESCRIPTIVES ON OUTPUT STATISTICS DATA SET"; proc means data=OutputStat1; run; TITLE "DESCRIPTIVES ON OUTREG1 DATA SET"; proc means data=outreg1; run; TITLE "CHECK DISTRIBUTION OF RESIDUALS"; proc univariate data=OutputStat1 plot normal; var studentresidual; histogram; qqplot / normal(mu=est sigma=est); run; TITLE1 "MULTIPLE REGRESSION ANALYSIS"; TITLE2 "WITH PERFECT COLLINEARITY"; proc reg data=labdata.werner3; model chol = age calc uric alb wt / stb tol vif collin; run;quit; /*********************************************************** Look at another data set ************************************************************/ title "Descriptive statistics for Baseball data set"; libname sasdata2 "d:\sasdata2"; proc means data=sasdata2.baseball; run; title "Correlation Matrix for Predictors and Outcome Variable"; proc corr data=sasdata2.baseball; var salary no_atbat no_hits no_home no_runs no_rbi; run; title "Linear Regression with Collinear Predictors"; proc reg data=sasdata2.baseball; model salary = no_atbat no_hits no_home no_runs no_rbi/ tol vif collin; run; quit; title "Modified Model, deleting one Predictor"; proc reg data=sasdata2.baseball; model salary = no_hits no_home no_runs no_rbi / tol vif collin; run; quit; title "Another Model"; proc reg data=sasdata2.baseball; model salary = no_hits no_rbi / tol vif collin; run; quit;