/************************ mathreg2.sas ****************************
*          Serious try at predicting final grade                  *
******************************************************************/

%include 'mathreadReplic.sas';
/* Quantitative Vars: precalc calc totscore hsgpa hscalc hsengl grade
   Categorical Vars:  course sex ethnic (6 cats)  tongue passed   
                      course = c1 c2 c3 (leave out c2 for standard)
                      gender is indicator for Female 
                      lang1 is indicator for English
                      ethnic = e1-e6: Leave out e3 to make European 
                               non-eastern the reference category.   */

options pagesize=100; /* Fewer page breaks */

safepred = -74.11274 + 1.60015*hsgpa + 0.29640 *hscalc + -0.35439*hsengl 
           + 1.90277*precalc; 
mypred = -67.76900  + -4.63620*lang1 + 4.84196*e5 + 1.57813*hsgpa 
           + 0.24943*hscalc + -0.32776*hsengl + 1.92570*precalc; 

sqerr1 = (grade-safepred)**2;
sqerr2 = (grade-mypred)**2;
diff = sqerr1-sqerr2;        /* For testing difference from mean zero */



proc reg;
     title2 'Politically safer model: 45% of the variation in exploration';
     model grade = hsgpa hscalc hsengl precalc;

proc reg;
     title2 'Only look at t-tests for lang1,  e5, hsengl and precalc';
     model grade = lang1 e5 hsgpa hscalc hsengl precalc;



proc means mean sum;
     title2 'Calculate SS Error of prediction';
     var sqerr1 sqerr2;
proc iml;
     Rsq1 = 1 - 62107.33/94377;
     print "Safe Model: Orig = 0.45 vs 0.36", Rsq1;
     Rsq2 = 1 -  61472.65/92102;
     print "My Model: Orig = 0.47 vs 0.36", Rsq2;

proc univariate; 
     title2 'Test for sig diff in accuracy';    
var diff;

