*DATA MINING SAS NOTES * *Linear regression and model diagnostics; *Importing data; data math5305lab2; infile 'C:\Users\jcrawford\Desktop\math5305Lab2Data.txt' dlm=','; input Y X1 X2 X3; proc print data=math5305lab2; run; *Multiple regression; proc reg data=math5305lab2; model Y=X1 X2 X3; run; *Multiple regression: Storing residuals in variable called myresiduals; proc reg data=math5305lab2; model Y=X1 X2 X3; output out=myoutput r=myresiduals; run; proc print data=myoutput; run; *Testing normality of residuals; proc univariate data=myoutput normal; var myresiduals; run; *Testing homoscedasticity of residuals (constancy of error variance); proc reg data=math5305lab2; model Y=X1 X2 X3/SPEC; run; *Histogram and qqplot for residuals; proc univariate data=myoutput; histogram myresiduals/normal; qqplot myresiduals; run; *Plot of Y vs each of the independent variables, X1, X2, and X3; proc plot data=myoutput; plot Y*X1 Y*X2 Y*X3; run; *Plot of residuals vs each independent variable; proc plot data=myoutput; plot myresiduals*X1 myresiduals*X2 myresiduals*X3; run; *Plotting within the regression command; proc reg data=math5305lab2; model Y=X1 X2 X3; output out=myoutput r=myresiduals; plot Y*X1 Y*X2 Y*X3; run; *Plotting with built in residuals and predicted values (yhat values); proc reg data=math5305lab2; model Y=X1 X2 X3; output out=myoutput r=myresiduals; plot Y*X1 Y*X2 Y*X3 residual.*X1 residual.*X2 residual.*X3 Y*predicted. residual.*predicted.; run;