/* MathReg2.sas */ %include '/folders/myfolders/441s16/Lecture/readmath2b.sas'; title2 'Residual analysis'; proc reg plots(only) = ResidualPlot; title3 'Model H: hsgpa hscalc hsengl totscore'; model grade = hsgpa hscalc hsengl totscore; output out = Explor predicted = yhat residual = resid rstudent = delstud; /* Deleted Studentized Residual */ /* Could have included LCL and UCL for upper and lower limits of a 95% prediction interval for each case in the file */ /* What is a big (Studentized deleted) residual? If the model is correct, each one has a t distribution with n-p-1 = 283 df (practically standard normal), so the Studentized deleted residual can be treated directly as a t-test statistic. Values that are too big in absolute value will cause H0: mu=0 to be rejected. Tests are NOT independent, but use a Bonferroni correction for n = 289 tests. Get the critical value from proc iml. */ proc iml; title3 'Critical value for Joint t-test on Studentized Residuals'; Alpha = 0.05/289; print Alpha; Critval = tinv(1-Alpha/2,283); print Critval; proc univariate normal plot; var delstud; /* Tests for normality indicate residuals are not normal. No st resids greater than critical value. Next, a few more plots. */ proc sgplot; title3 'Plot of Y-hat by Y'; scatter y=grade x=yhat; proc sgplot; title3 'Calculus sub-test by deleted studentized residual'; scatter x=calc y=delstud; proc sgplot; title3 'Pre-calculus sub-test by deleted studentized residual'; scatter x=precalc y=delstud; proc sgplot; title3 'Mother tongue by deleted studentized residual'; scatter x=mtongue y=delstud;