EZ Study

Actuarial Biology Chemistry Economics Calculators Confucius Engineer
Physics
C.S.


Logistic Regression Analysis Study Notes 1
Introduction to Logistic regression in SAS

Logistics regression is the most sexy part in Statistics-SAS body! It's simply because many people want to see that, want to get close to that, and have fun there ...

Many people may have not spent enough time there since it's always short time to have fun! It's actually the most difficult part in SAS-Statistics, evolving a lot of deep techniques ...

Download pdf • SAS Linear Regression Analysis, Linear Regression Analysis Study Notes

The following is the summary of the common logistics regression in sas:
  ods graphics on;
  ods trace on;  /* to see what tables might be available in output */ 
  ods output ParameterEstimates=Parameter1; /*output parameter estimate*/ 
  proc logistic data=Data1 descending  /* the same as (event='1');*/ 
  namelen=100 /* give enough length so not supress variables' output */
  /*namelen can be also applied in other regression e.g. proc glm */    
  plots=roc  /* generate ROC AUC(area under curve) ouptut */
 outest=Cov_betas covout; /*generate variance/covariance of variables*/
  model dep_var  (event='1') = &vars. 
  /CTABLE PPROB =(0 to 1 by .10)
 /*  generate the misclassification rate for each slice  */


     or  /CTABLE PPROB =(0.3, 0.5 to 0.8 by 0.1)
  /* generate the rate for cutoff at 0.3, 0.5, 0.6, 0.7, and 0.8*/  
  for example: Classification Table 
P_Level True_Pos True_neg False_Pos False_neg   %     Sensi   Speci   False_Pos_%  False_Neg_%  
0.000     75         0      572        0      11.6    100.0   0.0      88.4          .   
0.100     55       377      195       20      66.8    73.3    65.9     78.0        5.0   
0.200     28       502       70       47      81.9    37.3    87.8     71.4        8.6   
0.300     16       547       25       59      87.0    21.3    95.6     61.0        9.7   
...
0.800      1       572        0       74      88.6     1.3    100.0    0.0         11.5   
0.900      1       572        0       74      88.6     1.3    100.0    0.0         11.5   
1.000      0       572        0       75      88.4     0.0    100.0     .          11.6  
outroc=rocout /*generate the sensitivity and specifity output*/
oddsratio Heat / at(Soak=1 2 3 4); /*Odds Ratios of Heat at Several Values of Soak */ rsq /* generate generalized R Square measure for the model */ lackfit; performs the Hosmer and Lemeshow goodness-of-fit test for the binary response model. The subjects are divided into approximately 10 groups of roughly the same size based on the percentiles of the estimated probabilities. The discrepancies between the observed and expected number of observations in these groups are summarized by the Pearson chi-square statistic, which is then compared to a chi-square distribution with t degrees of freedom, where t is the number of groups minus n. By default, n = 2. A small p-value suggests that the fitted model is not an adequate model. Hosmer and Lemeshow Goodness-of-Fit Test Chi-Square DF Pr > ChiSq 4.6781 8 0.7914 weight split; /* if it's negative, missing or 0, then not used in the model*/ Output out=Data2 predicted=p_hat /* output the predictive prob. of each obs */ xbeta=xbeta; /*ouptut the value of all linear predictor x * beta, which is Y_hat*/ /*you can derive p_hat from xbeta by: p_hat=1/(1+exp(-xbeta))*/ Contrast statement: say a class variable has 4 levels, then 3 parameters for first 3 levels: b1,b2,b3 the last level as reference level:= -b1-b2-b3 compare the first with the last, b1=-b1-b2-b3 ==>2b1+b2+b3=0 Contrast '1 vs 4' A 2 1 1; compare the 3r with the avg of first 2, b3=(b1+b2)/2 ==>-b1-b2+2b3=0 Contrast '1&2 vs 3' A -1 -1 2; Contrast '1&2 vs 3&4' A 2 2 0; Contrast 'Main Effect' A 1 0 0, A 0 1 0, A 0 0 1; run; ods graphics off;
Acknowledgement: The tutorial is based on the notes from: www.ats.ucla.edu.

Continue to next: ROC/AUC Interpretation in SAS Logistic regression   Stats 101 Home   SAS tutorial home
Back to: Logistic regression: Data Preparation   Classic regression home   Experiment Design Statistics tutorial