This document provides an overview of binary logistic regression. It explains that binary logistic regression is used when the dependent variable is dichotomous (coded as 0 and 1). Ordinary least squares regression is not appropriate in this case because the assumptions of OLS are violated. Binary logistic regression transforms the dependent variable using the logit function to create a linear model that addresses these violations. The document outlines the key aspects of binary logistic regression including interpreting the coefficients, goodness of fit tests, and using the model to predict probabilities.
Download as PPT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
238 views
Binary Logistic Regression Lecture 9
This document provides an overview of binary logistic regression. It explains that binary logistic regression is used when the dependent variable is dichotomous (coded as 0 and 1). Ordinary least squares regression is not appropriate in this case because the assumptions of OLS are violated. Binary logistic regression transforms the dependent variable using the logit function to create a linear model that addresses these violations. The document outlines the key aspects of binary logistic regression including interpreting the coefficients, goodness of fit tests, and using the model to predict probabilities.
Binary Logistic Regression Binary logistic regression is a type of regression analysis where the dependent variable is a dummy variable (coded 0, 1) Why not just use ordinary least squares? Y = a + bx You would typically get the correct answers in terms of the sign and significance of coefficients However, there are three problems ^ Binary Logistic Regression OLS on a dichotomous dependent variable: Yes = 1 No = 0 X = Income Y = Support Privatizing Social Security 1 10 Binary Logistic Regression However, there are three problems 1. The error terms are heteroskedastic (variance of the dependent variable is different with different values of the independent variables 2. The error terms are not normally distributed 3. The predicted probabilities can be greater than 1 or less than 0, which can be a problem for subsequent analysis
Binary Logistic Regression The logit model solves these problems: ln[p/(1-p)] = a + BX or p/(1-p) = e a + BX p/(1-p) = e a (e B ) X
Where: ln is the natural logarithm, log exp , where e=2.71828 p is the probability that Y for cases equals 1, p (Y=1) 1-p is the probability that Y for cases equals 0, 1 p(Y=1) p/(1-p) is the odds ln[p/1-p] is the log odds, or logit
Binary Logistic Regression Logistic Distribution
Transformed, however, the log odds are linear. ln[p/(1-p)] P (Y=1) x x Binary Logistic Regression So what are natural logs and exponents? Ask Dr. Math. http://mathforum.org/library/drmath/view/55555.html ln(x) = y is same as: x = e y
READ THE ABOVE LIKE THIS: when you see ln(x) say the value after the equal sign is the power to which I need to take e to get x so y is the power to which you would take e to get x Binary Logistic Regression So ln[p/(1-p)] = y is same as: p/(1-p) = e y
READ THE ABOVE LIKE THIS: when you see ln[p/(1-P)] say the value after the equal sign is the power to which I need to take e to get p/(1-p) so y is the power to which you would take e to get p/(1-p) Binary Logistic Regression So ln[p/(1-p)] = a + bX is same as: p/(1-p) = e a
+ bX
READ THE ABOVE LIKE THIS: when you see ln[p/(1-P)] say the value after the equal sign is the power to which I need to take e to get p/(1-p) so a + bX is the power to which you would take e to get p/(1-p) Binary Logistic Regression The logistic regression model is simply a non-linear transformation of the linear regression. The logistic distribution is an S-shaped distribution function (cumulative density function) which is similar to the standard normal distribution and constrains the estimated probabilities to lie between 0 and 1.
Binary Logistic Regression Logistic Distribution With the logistic transformation, were fitting the model to the data better.
Transformed, however, the log odds are linear. P(Y = 1) 1 .5 0 X = 0 10 20 Ln[p/(1-p)] X = 0 10 20 Binary Logistic Regression Recall that OLS Regression used an ordinary least squares formula to create the linear model we used. The Logistic Regression model will be constructed by an iterative maximum likelihood procedure. This is a computer dependent program that: 1. starts with arbitrary values of the regression coefficients and constructs an initial model for predicting the observed data. 2. then evaluates errors in such prediction and changes the regression coefficients so as make the likelihood of the observed data greater under the new model. 3. repeats until the model converges, meaning the differences between the newest model and the previous model are trivial. The idea is that you find and report as statistics the parameters that are most likely to have produced your data. Model and inferential statistics will be different from OLS because of using this technique and because of the nature of the dependent variable. (Remember how we used chi-squared with classification?) Binary Logistic Regression Youre likely feeling overwhelmed, perhaps anxious about understanding this. Dont worry, coherence is gained when you see similarity to OLS regression: 1. Model fit 2. Interpreting coefficients 3. Inferential statistics 4. Predicting Y for values of the independent variables (the most difficult, but well make it easy) Binary Logistic Regression So in logistic regression, we will take the twisted concept of a transformed dependent variable equaling a line and manipulate the equation to untwist the interpretation. We will focus on: 1. Model fit 2. Interpreting coefficients 3. Inferential statistics 4. Predicting Y for values of the independent variables (the most difficult)the prediction of probability, appropriately, will be an S-shape Lets start with a research example and SPSS output
Binary Logistic Regression A researcher is interested in the likelihood of gun ownership in the US, and what would predict that. He uses the 2002 GSS to test the following research hypotheses: 1. Men are more likely to own guns than women 2. The older persons are, the more likely they are to own guns 3. White people are more likely to own guns than those of other races 4. The more educated persons are, the less likely they are to own guns Binary Logistic Regression Variables are measured as such: Dependent: Havegun: no gun = 0, own gun(s) = 1 Independent: 1. Sex: men = 0, women = 1 2. Age: entered as number of years 3. White: all other races = 0, white =1 4. Education: entered as number of years SPSS: Anyalyze Regression Binary Logistic Enter your variables and for output below, under options, I checked iteration history
Binary Logistic Regression SPSS Output: Some descriptive information first
Binary Logistic Regression SPSS Output: Some descriptive information first
Maximum likelihood process stops at third iteration and yields an intercept (-.625) for a model with no predictors. A measure of fit, -2 Log likelihood is generated. The equation producing this: -2((Yi * ln[P(Yi)] + (1-Yi) ln[1-P(Yi)]) This is simply the relationship between observed values for each case in your data and the models prediction for each case. The negative 2 makes this number distribute as a X 2 distribution. In a perfect model, -2 log likelihood would equal 0. Therefore, lower numbers imply better model fit.
Binary Logistic Regression Originally, the best guess for each person in the data set is 0, have no gun! This is the model for log odds when any other potential variable equals zero (null model). It predicts : P = .651, like above. 1/1+e a or 1/1+.535 Real P = .349 If you added each Binary Logistic Regression Next are iterations for our full model Binary Logistic Regression Goodness-of-fit statistics for new model come next Test of new model vs. intercept- only model (the null model), based on difference of -2LL of each. The difference has a X 2 distribution. Is new -2LL significantly smaller?
The -2LL number is ungrounded, but it has a 2
distribution. Smaller is better. In a perfect model, -2 log likelihood would equal 0. These are attempts to replicate R 2 using information based on -2 log likelihood, (C&S cannot equal 1) -2((Yi * ln[P(Yi)] + (1-Yi) ln[1-P(Yi)]) Assessment of new models predictions Binary Logistic Regression Interpreting Coefficients ln[p/(1-p)] = a + b 1 X 1 + b 2 X 2 + b 3 X 3 + b 4 X 4
b1 b2 b3 b4 a Being male, getting older, and being white have a positive effect on likelihood of owning a gun. On the other hand, education does not affect owning a gun.
Well discuss the Wald test in a moment
X1 X2 X3 X4 1 e b
Which bs are significant? ln[p/(1-p)] = a + b 1 X 1 + +b k X k , the power to which you need to take e to get: P P 1 P So 1 P = e a +
b1X1++bkXk
Ergo, plug in values of x to get the odds ( = p/1-p). Binary Logistic Regression The coefficients can be manipulated as follows: Odds = p/(1-p) = e a+b1X1+b2X2+b3X3+b4X4 = e a (e b1 ) X1 (e b2 ) X2 (e b3 ) X3 (e b4 ) X4
Odds = p/(1-p) = e a+.898X1+.008X2+1.249X3-.056X4 = e -1.864 (e .898 ) X1 (e .008 ) X2 (e 1.249 ) X3 (e -.056 ) X4
Binary Logistic Regression The coefficients can be manipulated as follows: Odds = p/(1-p) = e a+b1X1+b2X2+b3X3+b4X4 = e a (e b1 ) X1 (e b2 ) X2 (e b3 ) X3 (e b4 ) X4
Odds = p/(1-p) = e -2.246-.780X1+.020X2+1.618X3-.023X4 = e -2.246 (e -.780 ) X1 (e .020 ) X2 (e 1.618 ) X3 (e -.023 ) X4
Mrrr, Check it out! Each coefficient increases the odds by a multiplicative amount, the amount is e b . Every unit increase in X increases the odds by e b . In the example above, e b = Exp(B) in the last column.
Binary Logistic Regression Each coefficient increases the odds by a multiplicative amount, the amount is e b . Every unit increase in X increases the odds by e b . In the example above, e b = Exp(B) in the last column. For Sex: e -.780 = .458 If you subtract 1 from this value, you get the proportion increase (or decrease) in the odds caused by being male, -.542. In percent terms, odds of owning a gun decrease 54.2% for women. Age: e .020 = 1.020 A year increase in age increases the odds of owning a gun 2%. White: e 1.618 = 5.044 Being white increases the odd of owning a gun by 404% Educ: e -.023 = .977 Not significant Binary Logistic Regression Age: e .020 = 1.020 A year increase in age increases the odds of owning a gun 2%. How would 10 years increase in age affect the odds? Recall (e b ) X is the equation component for a variable. For 10 years, (1.020) 10 = 1.219. The odds jump by 22% for ten years increase in age. Note: Youd have to know the current prediction level for the dependent variable to know if this percent change is actually making a big difference or not! Binary Logistic Regression Note: Youd have to know the current prediction level for the dependent variable to know if this percent change is actually making a big difference or not! Recall that the logistic regression tells us two things at once. Transformed, the log odds are linear.
Logistic Distribution
ln[p/(1-p)] P (Y=1) x x Binary Logistic Regression We can also get p(y=1) for particular folks. Odds = p/(1-p); p = P(Y=1) With algebra Odds(1-p) = p Odds-p(odds) = p Odds = p+p(odds) Odds = p(1+odds) Odds/1+odds = p or p = Odds/(1+odds) Ln(odds) = a + bx and odds = e a + bx
so P = e a+bX /(1+ e a+bX ) We can therefore plug in numbers for X to get P If a + BX = 0, then p = .5 As a + BX gets really big, p approaches 1 As a + BX gets really small, p approaches 0 (our model is an S curve) Binary Logistic Regression For our problem, P = e -2.246-.780X1+.020X2+1.618X3-.023X4
1 + e -2.246-.780X1+.020X2+1.618X3-.023X4
For, a man, 30, Latino, and 12 years of education, the P equals? Lets solve for e -2.246-.780X1+.020X2+1.618X3-.023X4 = e -2.246-.780(0)+.020(30)+1.618(0)-.023(12)
e -2.246 0 + .6
+ 0 - .276 = e -1.922 = 2.71828 -1.922 = .146 Therefore, P = .146 = .127 The probability that the 30 year-old, Latino with 12 1.146 years of education will own a gun is .127!!! Or you could say there is a 12.7% chance.
Binary Logistic Regression Inferential statistics are as before:
In model fit, if 2 test is significant, the expanded model (with your variables), improves prediction.
This Chi-squared test tells us that as a set, the variables improve classification.
Binary Logistic Regression Inferential statistics are as before:
The significance of the coefficients is determined by a wald test. Wald is 2 with 1 df and equals a two-tailed t 2 with p-value exactly the same. Binary Logistic Regression
1. Significance test for -level = .05 2. Critical X 2 df=1 = 3.84 3.To find if there is a significant slope in the population, H o :
= 0 H a :
0 4.Collect Data 5.Calculate Wald, like t (z): t = b o (1.96 * 1.96 = 3.84)
s.e. 6.Make decision about the null hypothesis 7.Find P-value
So how would I do hypothesis testing? An Example: Reject the null for Male, age, and white. Fail to reject the null for education. There is a 24.2% chance that the sample came from a population where the education coefficient equals 0.