OPTIONS NODATE LS=77 PS=60 NODATE PAGENO=1; TITLE 'Logistic Regression and Odds Ratio'; DATA one; INPUT months y success $; DATALINES; 14 0 No 29 0 No 6 0 No 25 1 Yes 18 1 Yes 4 0 No 18 0 No 12 0 No 22 1 Yes 6 0 No 30 1 Yes 11 0 No 30 1 Yes 5 0 No 20 1 Yes 13 0 No 9 0 No 32 1 Yes 24 0 No 13 1 Yes 19 0 No 4 0 No 28 1 Yes 22 1 Yes 8 1 Yes ; /* LS straight line regression */ PROC REG DATA=one; MODEL y = months / P CLM; RUN; /* Logistic regression. (event='Yes') defines pi=P(Yes), not pi=P(No).*/ PROC LOGISTIC DATA=one; MODEL success (EVENT='Yes') = months; OUTPUT OUT=two P=predicted L=lower U=upper; RUN; PROC PRINT DATA=two; VAR months success predicted lower upper; RUN; QUIT; ************************************************************************ Logistic Regression and Odds Ratio 1 The REG Procedure Model: MODEL1 Dependent Variable: y Number of Observations Read 25 Number of Observations Used 25 Analysis of Variance Sum of Mean Source DF Squares Square F Value Pr > F Model 1 1.96484 1.96484 10.77 0.0033 Error 23 4.19516 0.18240 Corrected Total 24 6.16000 Root MSE 0.42708 R-Square 0.3190 Dependent Mean 0.44000 Adj R-Sq 0.2894 Coeff Var 97.06388 Parameter Estimates Parameter Standard Variable DF Estimate Error t Value Pr > |t| Intercept 1 -0.09220 0.18327 -0.50 0.6197 months 1 0.03153 0.00961 3.28 0.0033 Logistic Regression and Odds Ratio 2 The REG Procedure Model: MODEL1 Dependent Variable: y Output Statistics Dependent Predicted Std Error Obs Variable Value Mean Predict 95% CL Mean Residual 1 0 0.3492 0.0898 0.1635 0.5349 -0.3492 2 0 0.8221 0.1444 0.5234 1.1208 -0.8221 3 0 0.0970 0.1350 -0.1823 0.3762 -0.0970 4 1.0000 0.6960 0.1157 0.4567 0.9353 0.3040 5 1.0000 0.4753 0.0861 0.2972 0.6534 0.5247 6 0 0.0339 0.1503 -0.2771 0.3449 -0.0339 7 0 0.4753 0.0861 0.2972 0.6534 -0.4753 8 0 0.2861 0.0974 0.0846 0.4877 -0.2861 9 1.0000 0.6014 0.0986 0.3975 0.8053 0.3986 10 0 0.0970 0.1350 -0.1823 0.3762 -0.0970 11 1.0000 0.8537 0.1522 0.5387 1.1686 0.1463 12 0 0.2546 0.1024 0.0428 0.4665 -0.2546 13 1.0000 0.8537 0.1522 0.5387 1.1686 0.1463 14 0 0.0654 0.1425 -0.2294 0.3603 -0.0654 15 1.0000 0.5384 0.0905 0.3511 0.7256 0.4616 16 0 0.3177 0.0932 0.1249 0.5105 -0.3177 17 0 0.1916 0.1141 -0.0445 0.4277 -0.1916 18 1.0000 0.9167 0.1685 0.5681 1.2653 0.0833 19 0 0.6645 0.1094 0.4381 0.8908 -0.6645 20 1.0000 0.3177 0.0932 0.1249 0.5105 0.6823 21 0 0.5068 0.0878 0.3252 0.6885 -0.5068 22 0 0.0339 0.1503 -0.2771 0.3449 -0.0339 23 1.0000 0.7906 0.1368 0.5077 1.0735 0.2094 24 1.0000 0.6014 0.0986 0.3975 0.8053 0.3986 25 1.0000 0.1600 0.1207 -0.0897 0.4097 0.8400 Sum of Residuals 0 Sum of Squared Residuals 4.19516 Predicted Residual SS (PRESS) 4.83784 Logistic Regression and Odds Ratio 3 The LOGISTIC Procedure Model Information Data Set WORK.ONE Response Variable success Number of Response Levels 2 Model binary logit Optimization Technique Fisher's scoring Number of Observations Read 25 Number of Observations Used 25 Response Profile Ordered Total Value success Frequency 1 No 14 2 Yes 11 Probability modeled is success='Yes'. Model Convergence Status Convergence criterion (GCONV=1E-8) satisfied. Model Fit Statistics Intercept Intercept and Criterion Only Covariates AIC 36.296 29.425 SC 37.515 31.862 -2 Log L 34.296 25.425 Testing Global Null Hypothesis: BETA=0 Test Chi-Square DF Pr > ChiSq Likelihood Ratio 8.8719 1 0.0029 Score 7.9742 1 0.0047 Wald 6.1760 1 0.0129 Logistic Regression and Odds Ratio 4 The LOGISTIC Procedure Analysis of Maximum Likelihood Estimates Standard Wald Parameter DF Estimate Error Chi-Square Pr > ChiSq Intercept 1 -3.0597 1.2594 5.9029 0.0151 months 1 0.1615 0.0650 6.1760 0.0129 Odds Ratio Estimates Point 95% Wald Effect Estimate Confidence Limits months 1.175 1.035 1.335 Association of Predicted Probabilities and Observed Responses Percent Concordant 82.5 Somers' D 0.662 Percent Discordant 16.2 Gamma 0.671 Percent Tied 1.3 Tau-a 0.340 Pairs 154 c 0.831 Logistic Regression and Odds Ratio 5 Obs months success predicted lower upper 1 14 No 0.31026 0.13279 0.56923 2 29 No 0.83526 0.47767 0.96565 3 6 No 0.11000 0.02024 0.42512 4 25 Yes 0.72660 0.41475 0.90882 5 18 Yes 0.46184 0.24746 0.69132 6 4 No 0.08213 0.01186 0.40009 7 18 No 0.46184 0.24746 0.69132 8 12 No 0.24567 0.08811 0.52328 9 22 Yes 0.62081 0.35398 0.83028 10 6 No 0.11000 0.02024 0.42512 11 30 Yes 0.85630 0.49130 0.97352 12 11 No 0.21698 0.07040 0.50345 13 30 Yes 0.85630 0.49130 0.97352 14 5 No 0.09515 0.01552 0.41228 15 20 Yes 0.54240 0.30426 0.76263 16 13 No 0.27680 0.10893 0.54511 17 9 No 0.16710 0.04365 0.46863 18 32 Yes 0.89166 0.51682 0.98446 19 24 No 0.69338 0.39612 0.88631 20 13 Yes 0.27680 0.10893 0.54511 21 19 No 0.50213 0.27658 0.72682 22 4 No 0.08213 0.01186 0.40009 23 28 Yes 0.81182 0.46334 0.95567 24 22 Yes 0.62081 0.35398 0.83028 25 8 Yes 0.14582 0.03397 0.45315