
LOG CONTAINING MODELLING STEPS FOR POLYNESIAN ISLAND 
DATASET, FOLLOWING UP ON STEPS IN LOGISREG.LOG
======================================= 12/12/08


libname SAS "SASdat";
options nocenter linesize=75 nodate ;

/* The following scatterplot from LEC8log
showed interesting interaction between
the latitS and tephra variables as predictors 
for Deforstn */

symbol1 v= circle color=black;
symbol2 v= square color=red;
symbol3 v= diamond color=blue;

proc gplot data=SAS.polynest;
  title "Scatterplot with controlled plotting symbols";
   plot deforstn*latitS = tephra ;
   run;

data tmpPoly;
   set SAS.polynest;
   if Deforstn ne . ;
   HIdefrst = int(Deforstn/3);
   abslat = abs(LatitS);
run;                   /* 79 obs, 18 varbls */

data tmppoly2;
   set tmppoly;
    latElv = abslat*elev;  latIsol = abslat*isol_25;
    latRain= abslat*rain;  latTeph = abslat*tephra;
    elvIso = elev*isol_25;  elvRain = elev*rain;
    elvTeph = elev*tephra; IsoRain = isol_25*rain;
    rainTeph = rain*tephra; IsoTep = isol_25*tephra; run;

proc reg data=tmppoly2;
    model deforstn = elev isol_25 abslat rain tephra
     latElv latIsol latRain latTeph elvIso elvRain 
     elvTeph IsoRain rainTeph IsoTep / 
       selection = forward sle = .05 aic r include=5;
   run;
                Parameter     Standard
  Variable      Estimate        Error   Type II SS  F Value  Pr > F

  Intercept      2.13987      0.52294      5.49853    16.74  0.0001
* Elev       -0.00011512   0.00007756      0.72347     2.20  0.1422
* Isol_25     0.00012537   0.00014696      0.23899     0.73  0.3965
* abslat         0.11586      0.02730      5.91416    18.01  <.0001
* Rain       -0.00025990   0.00006320      5.55294    16.91  0.0001
* Tephra         0.39122      0.22040      1.03458     3.15  0.0802
  latTeph       -0.03393      0.01136      2.92652     8.91  0.0039

           * Forced into the model by the INCLUDE= option


The REG Procedure
Model: MODEL1
Dependent Variable: Deforstn

Forward Selection: Step 1

Bounds on condition number: 13.756, 220.06
---------------------------------------------------------------------------
No other variable met the 0.0500 significance level for entry into the
model.


                     Summary of Forward Selection

      Variable   Number   Partial    Model
Step  Entered    Vars In  R-Square  R-Square   C(p)    F Value  Pr > F

  1   latTeph        6     0.0512    0.5921    1.4495     8.91  0.0039

proc reg data=tmppoly2;
    model deforstn = elev isol_25 abslat rain tephra
     latTeph latitS;
  plot residual.*predicted.;
  plot residual.*latitS;  
  plot deforstn * latitS;
   run;

/* LatitS is quite insignificant, but plots show interestingly
  how the observations break down according to latitude; can 
  look for subgroups, which is what the geographers Rolett & 
  Diamond did ... 

  Because of the breakdown into subgroups, can look for 
  higher-order interactions; but in an 80-observation dataset
  there is a sense of diminishing return in doing so !

  Recall that we cannot really trust the p-values because the 
  residuals are so non-normal. Nevertheless, in constructing 
  residuals plots versus INDIVIDUAL variables instead of the 
  overall predictor, the stripey form of the residuals 
  disappears.  */ 


data tmppoly3;
   set tmppoly2;
    latElvRa = abslat*elev*rain;  ageRa = age*rain;
    elvraTeph = elev*rain*tephra; Rainsq = Rain**2; run;


proc reg data=tmppoly3;
    model deforstn = elev abslat rain tephra
     latTeph latElvRa ageRa elvraTeph  / 
       selection = forward sle = .05 aic r include=5;
run;

/* But with the SLE=.05 critrion, no new variables 
   get included into the model !!  */

               Parameter     Standard
  Variable      Estimate        Error   Type II SS  F Value  Pr > F

  Intercept      2.36149      0.47665      6.63699    24.55  <.0001
* Elev       -0.00015471   0.00006544      1.51138     5.59  0.0209
* abslat         0.10988      0.02447      5.45301    20.17  <.0001
* Rain       -0.00026085   0.00005736      5.59198    20.68  <.0001
* Tephra         0.33601      0.20075      0.75748     2.80  0.0987
* latTeph       -0.03040      0.01022      2.39199     8.85  0.0040

/* Note that the Tephra variable is worth keeping because 
      its Type III SSQ contribution together with the 
      latitude by Tephra interaction are large enough !!  */

proc glm data=tmppoly3;  
      model deforstn = abslat rain tephra latTeph elev ;
   run;

/* The elev contribution is quite insignificant in the 
     present of the other variables. A tentative pruned final 
     form of the model is as follows. I would still check 
     residuals plots to see that the model-builsing is over ... */

proc reg data=tmppoly3;  
      model deforstn = abslat rain tephra latTeph ;
      output out=outPoly p = DefPred r = DefRes Student = StdRes ;
   run;

The REG Procedure
Model: MODEL1
Dependent Variable: Deforstn

                        Parameter Estimates

                     Parameter       Standard
Variable     DF       Estimate          Error    t Value    Pr > |t|

Intercept     1        1.98019        0.51270       3.86      0.0002
abslat        1        0.12271        0.02675       4.59      <.0001
Rain          1    -0.00026945     0.00006293      -4.28      <.0001
Tephra        1        0.42108        0.21968       1.92      0.0592
latTeph       1       -0.03726        0.01112      -3.35      0.0013


proc gplot data=outpoly;
   plot DefRes* age = 1;    /* a little curvature but only 4 ages !!*/
   plot StdRes* rain = 2;   
            /* generally a clear increasing tendency at the 
              largest rainfall levels */
run;

proc reg data=tmpPoly3;
   model  deforstn = abslat rain tephra latTeph rainsq;
   plot residual. * rain; 
   plot deforstn*predicted. ; run;

/* The final predictive plot shows that for these 5 
     distinct levels of response there is not much more to hope for by
     way of prediction !!  R-square = .603  */


Variable     DF       Estimate          Error    t Value    Pr > |t|

Intercept     1        2.23292        0.51644       4.32      <.0001
abslat        1        0.12550        0.02621       4.79      <.0001
Rain          1    -0.00060968     0.00017622      -3.46      0.0009
Tephra        1        0.53045        0.22141       2.40      0.0192
latTeph       1       -0.04036        0.01098      -3.68      0.0005
Rainsq        1    5.167404E-8    2.507785E-8       2.06      0.0430

/* DOES NOT PAY TO GO FARTHER BECAUSE THE DATASET IS SMALL ! SOME OF
THE ATTEMPTED FITTING OF INTERACTION TERMS IS NO DOUBT FRUSTRATED BY
THE PRESENT OF CONSIDERABLE MISSING VALUES !! */


