options ls=80; data dwaine; input x1 x2 y; x12=x1*x2; label y=Sales x1=Number of persons aged 16 or younger x2=Per capita disposable personal income; datalines; 68.5 16.7 174.4 45.2 16.8 164.4 91.3 18.2 244.2 47.8 16.3 154.6 46.9 17.3 181.6 66.1 18.2 207.5 49.5 15.9 152.8 52.0 17.2 163.2 48.9 16.6 145.4 38.4 16.0 137.2 87.9 18.3 241.9 72.8 17.1 191.1 88.4 17.4 232.0 42.9 15.8 145.3 52.5 17.8 161.1 85.7 18.4 209.7 41.3 16.5 146.4 51.7 16.3 144.0 89.6 18.1 232.6 82.7 19.1 224.1 52.3 16.0 166.5 ; Title1 'Section 6.9 page 237-247'; proc reg data=dwaine; model y=x1 x2/ covb xpx i corrb; /* covb gives the variance covariance matrix xpx gives the X'X matrix i gives the inverse of the X'X matrix corrb gives the correlation matrix */ output out=dwaine p=pred r=resid; data dwaine; set dwaine; absresid=abs(resid); /* Above SAS statement defines the absolute values of the residuals */ proc plot data=dwaine; plot resid*pred; title2 'Residual plot against yhat(predicted value)'; title3 'Fig 6.8 (a)'; proc plot data=dwaine; plot resid*x1; title2 'Residual plot against x1'; title3 'Fig 6.8 (b)'; proc plot data=dwaine; plot resid*x2; title2 'Residual plot against x2'; title3 'Fig 6.8 (c)'; proc plot data=dwaine; plot resid*x12; title2 'Residual plot against x1*x2'; title3 'Fig 6.8 (d)'; proc plot data=dwaine; plot absresid*pred; title2 'Absolute residual plot against predicted value'; title3 'Fig 6.9 (a)'; proc capability data =dwaine noprint; probplot resid; title2 'Normal probability plot'; title3 'Fig 6.9 (b)'; proc corr data=dwaine; var y pred; title2 'To show that CORR(YHAT,Y)=SQRT(R^2)'; proc univariate data=dwaine normal; var resid; title2 ' Test for normality-Shapiro-Wilks test etc'; proc reg data=dwaine; model y=x1 x2 x12; title2 'Interaction model'; data tvalues; a=tinv(.9875,18); b=tinv(.99166666,18); c=finv(0.95,3,18); d=finv(0.95,2,18); proc print data=tvalues; title2 'For joint inferences we need to find'; title3 ' t & F-percentiles not in the tables'; /* Title should be limited to 40 characters */ run;