A tutorial presenting the core features of PROC ... Enhancements to PROC
LOGISTIC in Version 8 of the .... proc logistic data=miner.sample descending;.
Getting Started With PROC LOGISTIC Andrew H. Karp Sierra Information Services, Inc. 19229 Sonoma Hwy. PMB 264 Sonoma, California 95476 707 996 7380
[email protected]
www.SierraInformation.com
Getting Started with PROC LOGISTIC • A tutorial presenting the core features of PROC LOGISTIC – not an exhaustive treatment of all aspects of the procedure, or of all topics related to models with categorical dependent variables – designed to help new users of the procedure
SAS is a registered trademark of SAS Institute, Inc. in the USA and other countries. ® indicates USA registration. This document copyright © 2004 by Sierra Information Services, Inc. All rights reserved, and may not be duplicated without the express written consent of the copyright holder.
Getting Started With PROC LOGISTIC • This tutorial gives an introduction to implementing several common forms of logistic regression model using PROC LOGISTIC. You will learn: – how to prepare your data for analysis by PROC LOGISTIC – how to implement several forms of logistic regression models using PROC LOGISTIC – Enhancements to PROC LOGISTIC in Version 8 of the SAS System • What’s new in SAS 9
Getting Started with PROC LOGISTIC • When do we use Logistic Regression ? • Logistic Regression is commonly used to predict the probability that a unit under analysis will “acquire the event of interest” as a function of changes in values of one or more – continuous-level variables – dichotomous (binary variables) or a combination of both continuous and binary independent variables
• In many studies the “event” is a considered a dichotomous “outcome” SAS is a registered trademark of SAS Institute, Inc. in the USA and other countries. ® indicates USA registration. This document copyright © 2004 by Sierra Information Services, Inc. All rights reserved, and may not be duplicated without the express written consent of the copyright holder.
Getting Started with PROC LOGISTIC • “Binary outcomes” are of interest in many different fields of study: – Marketing: will the customer re-purchase the product? – Medicine: will the patient live or die? – Sociology: will the professor receive or be denied tenure? – Criminology: will the released convict commit another crime? – Economics: will a woman return to the workplace after giving birth?
Getting Started with PROC LOGISTIC: Coding the Dependent Variable • In logistic regression, the dependent variable is dichotomous and is usually coded either: – zero (event did not occur) – one (event did occur) • The logistic function is used to estimate, as a function of unit changes in the independent variable(s) the probability that the event of interest will occur
SAS is a registered trademark of SAS Institute, Inc. in the USA and other countries. ® indicates USA registration. This document copyright © 2004 by Sierra Information Services, Inc. All rights reserved, and may not be duplicated without the express written consent of the copyright holder.
The Logistic Function • The logistic function is:
β0 +β1X1+β2X2.....βnXn
e p(y =1) = β0+β1X1+β2X2.....βnXn 1+e and gives the probability of the event of interest (usually coded 1) of occurring.
Implementing a Logistic Regression Model Using the SAS System for Logistic Regression Logistic Regression Model Plot of PROBPASS*SAT.
Symbol used is '*'.
1 ˆ * * * * * * * * * * * * * * * * * * * * ‚ * * ‚ * ‚ ‚ * ‚ 0.8 ˆ ‚ * ‚ PROBPASS ‚ ‚ * ‚ 0.6 ˆ ‚ ‚ * ‚ ‚ ‚ 0.4 ˆ ‚ * ‚ ‚ ‚ * ‚ 0.2 ˆ ‚ * ‚ ‚ * ‚ * ‚ * * 0 ˆ * * * * * * * * * * * * * * * * * * * * * * * * * * * Šƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒƒƒƒƒƒƒƒˆƒƒ 200 250 300 350 400 450 500 550 600 650 700 750 800 SAT
SAS is a registered trademark of SAS Institute, Inc. in the USA and other countries. ® indicates USA registration. This document copyright © 2004 by Sierra Information Services, Inc. All rights reserved, and may not be duplicated without the express written consent of the copyright holder.
More About the Logistic Function • Provides a statistically superior alternative to the General Linear Model in situations where the dependent variable is dichotomous rather than continuous – “Maps” or “translates” changes in values of the independent variables into a probability that ranges between zero and one – Exponentiation of the parameter estimates yields an easily interpretable value: the odds ratio
Implementation of Logistic Regression Techniques in the SAS System
• Logistic regression techniques are implemented in the LOGISTIC procedure, included in the STAT Module of SAS System Software • Other tools for categorical data analysis are found in the: – FREQ, CATMOD – GENMOD, PHREG
procedures in the STAT Module SAS is a registered trademark of SAS Institute, Inc. in the USA and other countries. ® indicates USA registration. This document copyright © 2004 by Sierra Information Services, Inc. All rights reserved, and may not be duplicated without the express written consent of the copyright holder.
Preparing your data for use by PROC LOGISTIC • How you code the values of your dependent variable is important! – the zero/one coding scheme is the most commonly used method to indicate nonevent/event for the dependent variable – by default, however, PROC LOGISTIC will attempt to model (that is, predict the probability of) the lower of the two values, which is usually not the desired result.
Effects of Coding the Dependent Variable • Example: Study of whether a customer responds to a product offer – 0 (zero): customer did not buy – 1 (one) : customer did buy – By default, PROC LOGISTIC will implement a model to predict the probability of the event coded zero, not the event coded one. – This is usually contrary to what we want PROC LOGISTIC to do!
SAS is a registered trademark of SAS Institute, Inc. in the USA and other countries. ® indicates USA registration. This document copyright © 2004 by Sierra Information Services, Inc. All rights reserved, and may not be duplicated without the express written consent of the copyright holder.
The DESCENDING Option
• If your data are coded zero/one, you can override the default attempt to predict the probability of non-event by: – re-coding the dependent variable in a Data Step – using a FORMAT where the ‘event’ group is ‘higher’ than the ‘non-event’ group – using the DESCENDING option in the PROC LOGISTIC statement • DESCENDING option added to the SAS System in Release 6.07
Implementing a Logistic Regression Equation • Key points to remember: – Logistic regression creates a model which attempts to predict the probability of an event of interest occurring in the population from which the data under analysis are assumed to have been randomly sampled – Changes in the values of the independent variables are often expressed in the context of changes (if any) in the odds ratio • how do unit increases in the independent variable(s) contained in the model increase or decrease the odds the outcome of interest will occur.
SAS is a registered trademark of SAS Institute, Inc. in the USA and other countries. ® indicates USA registration. This document copyright © 2004 by Sierra Information Services, Inc. All rights reserved, and may not be duplicated without the express written consent of the copyright holder.
Using PROC LOGISTIC to Implement a Logistic Regression Equation • The structure and syntax of many statements in PROC LOGISTIC are similar to those used in PROC REG and PROC GLM. – The important difference is what is being estimated and what the parameter estimates mean in a logistic regression vs. a linear regression model.
The general form of PROC LOGISTIC is: PROC LOGISTIC DATA=dsn [DESCENDING] ; MODEL depvar = indepvar(s)/options; RUN;
Implementing a Logistic Regression Model • Example: Customer Purchase Study Outcome (dependent variable): Customer Purchased Product – 1 = “Bought” 0 = “Did not Buy”
• Independent variable: Number of Days Since Last Purchase (Recency)
SAS is a registered trademark of SAS Institute, Inc. in the USA and other countries. ® indicates USA registration. This document copyright © 2004 by Sierra Information Services, Inc. All rights reserved, and may not be duplicated without the express written consent of the copyright holder.
Implementing a Simple Logistic Regression Model in Version 8 of the SAS System ods html close; ods listing; ods html path= 'c:\wells\miner' (url=none) body ='model1.htm‘ style = styles.andrew5 ;
proc logistic data=miner.sample descending; model respond = DaysSinceLastPurchase; units DaysSinceLastPurchase=30 60 90 180 365; run; ods html close; ods listing;
Implementing a Simple Logistic Regression Model in Version 8 of the SAS System Model Information Data Set
WORK.SAMPLE
Response Variable
respond
Number of Response Levels
2
Number of Observations
967
Link Function
Logit
Optimization Technique
Fisher's scoring
Did Cust. Respond
Response Profile Ordered Value respond
Total Frequency
1 1
491
2 0
476
Model Convergence Status Convergence criterion (GCONV=1E-8) satisfied.
SAS is a registered trademark of SAS Institute, Inc. in the USA and other countries. ® indicates USA registration. This document copyright © 2004 by Sierra Information Services, Inc. All rights reserved, and may not be duplicated without the express written consent of the copyright holder.
Implementing a Simple Logistic Regression Model in Version 8 of the SAS System
Model Fit Statistics
Criterion
Intercept Only
Intercept and Covariates
AIC
1342.314
1312.646
SC
1347.188
1322.394
-2 Log L
1340.314
1308.646
Implementing a Simple Logistic Regression Model in Version 8 of the SAS System
Testing Global Null Hypothesis: BETA=0 Test
Chi-Square
DF
Pr > ChiSq
Likelihood Ratio
31.6682
1
ChiSq
Likelihood Ratio
48.8306
2