/* mathlogreg4.sas */ %include '/home/u1407221/441s24/SAS08/ReadLabelMath2.sas'; title2 'Prediction for the replication sample'; /* Where should we draw the line, and predict that the student will pass? In the exploratory sample, 52.68% passed overall, so find the pihat that cuts off the bottom 52.68%, and use that as a cutoff. There was a pihat right at the 52.68th percentile: 0.4063743825. If pihat > 0.406, predict the student will pass. For the record and before peeking, I predict 75% correct. */ data mathrep; set replic; if hsgpa+hscalc+precalc = . then missused = 1 ; else missused = 0; label missused = 'Any of hsgpa hscalc precalc missing'; format missused ynfmt.; /* Pi-hat when predictors are not missing, from mathlogreg2 results */ b0 = -14.7970; b1 = 0.1173; b2 = 0.0638; b3 = 0.2989; L = b0 + b1*hsgpa + b2*hscalc + b3*precalc; pihat = exp(L)/(1+exp(L)); if missused=1 then pihat = 0.348; if pihat > 0.406 then Prediction = 'Pass '; else Prediction = 'Not Pass'; /* Check commented out proc means; title3 'Checking Prediction Variable: pihat > 0.406'; class Prediction; var pihat; */ proc freq data = mathrep; title2 'How good is the prediction?'; tables Prediction*passed / nocol; proc iml; PercentCorrect = 35.75 + 34.54; print PercentCorrect; /* Prediction may be better at the extremes. */ proc freq data = mathrep; tables pihat*passed / norow nocol nopercent; run; quit;