At this point, I think it's better to start looking at an actual example. That will hopefully solidify and clarify your understanding of logistic regression. So here's some made up data of the Acme Widget Company. They did this by survey of customer's choice, of buying some widget on 20 occasions, so we got 20 data points. We decided to use a number of discounts. No discount here, no discount, a $50 discount, $100 discount, etc. So increments of 50 from 0-200 and here, you can see the way that data is set up. The first group of items has no discount. In this case, 1, 2, 3, 4, 5, 6, one out of six individuals decided to make the purchase without any discount. Now, your intuition should tell you that the steeper the discount or the bigger the discount, the more likely they would buy, holding other things constant. So at the $200 discount here, you can see that there were two choices to purchase with $150 discount, two-thirds of the people selected to purchase, and then here's the $100 discount, and then it decreases. So our data sample, we have 20 occasions or n equals 20, our independent variable is the discount which ranges from 0-200 in increments of 50. It doesn't have to be in increments of 50. Our binary choice variable is a one when the customer buys and it's a zero when they don't buy. So one means buy and zero means don't buy. So we're going to try to figure out what the probabilities are by using this model here. So here's our Logit Function, Beta 0, Beta 1 times the discount. So before I go to this results, let's look at our note to calculate. All right. So here I am in the R environment. Let me clean up some of this stuff from before. Clean up mine as well, clean up the environment. I have two variables; the discount and the buy variable, and I can cbind discount,buy. You can see here that I have essentially coded in what was on the PowerPoint slide. So one person bought with a discount of zero, and then you see down here at a $200 discount, everybody bought, etc., so there it is. Here is the line to actually run the regression. In some levels, in some regards, the actual code to run it in R is not complicated. The trick is all about the interpretation. So here, look at this side. GLM is a general linear model and your dependent variable is buy, and then you put your tilde and then your independent variables to the right of the tilde. That's the squiggly line, it's the tilde. Then family equals binomial. That's how it knows it's a binary choice model. I'm going to run this and I'm going to put it into the variable ex1. This is standard R techniques of running a regression of any sort. You put the results into some variable name and then you say give me the summary of that variable name. So let's do that. Here, I named the variable ex1 for example 1, and there it is. We can look, there's the formula. Here are the estimates of the Beta, so Beta 1 is estimated to be minus 1.45 and 0.02 for the Beta 1 number. So let's go back to the PowerPoint slides and I'll talk through the interpretation. So here, I have essentially just cut and paste the R results in here. There are the estimates right here. They are significant at the 0.05 level, and the intercept term is significant at the 0.1 level. Well, let's just go with it for now. Here's our model. So the logit function, the log of the odds is equal to minus 1.46, comes from right here, plus two times the discount, so I've copied at the top. So Beta 0 is 1.46 is the log odds of buying a widget when there is no discount. Beta 1 is equal to 0.02 times the amount of the discount, so recall it was 50, 100, 150, 200. It's the difference in the log odds of the widget when the discount is compared to when there is no discount. You can think of it that way. So let's take a concrete example. So I think that makes a lot more sense. If the discount is $100, then Beta 0 plus Beta 1 is equal to minus 1.46, that's the intercept term, plus 0.02 times 100 which happens to equal 0.54. That is the log odds of buying a widget when there's a discount of $100 discount. So we're going to have to keep in mind these two formulas, if the log of a is equal to b, then if you exponentiate both sides, e to the log of a is equal to the e to the b. Log odds of Beta 0, the log odds we've determined from our regression if there's no discount is Beta 0, then our odds are e to the Beta 0. So let's calculate the odds. When there is no discount, x is 0, the log odds is Beta 0 plus Beta 1 times 0 or Beta 0. Then we just exponentiate, so e to the minus 1.46 is 0.23. So those are the odds. I think most people are more comfortable about thinking of these things in terms of probability than odds. So probability of buying a widget without a discount, you just plug it into that formula of P, Probability is equal to the odds over 1 plus the odds. So that's what this is, odds 0.2322 over one plus the odds, and that equals 18.8 or about 19 percent. So there's a 19 percent chance of someone buying this widget with no discount. Your intuition should tell you as the discounts go up, this number should also go up. So let's take an example where x is equal to 100. So here we go, the log odds are minus 1.46 plus 0.02 times 100, and we get this value of 0.54. This is equal to 0.54 and then e to the 0.54 is 1.716. Remember those are the odds, so then we want to convert to probability and we have this value here. So there's a 63 percent chance of a person buying the widget with $100 discount. Let's recap real quick. So far, we should have an understanding of what the logit model is, the logit function is, and that sharp S curve and why we chose a function without S curve. We should know how to interpret the coefficients and the logit function, especially via specific example. In some sense, it's not as easy as to interpret as linear regression. Linear regression is just a one unit change in x. It's equal to a Beta change in Y. You have to go through these little mathematical transformations to get the probability. Over time, you should be able to think in terms of odds, but let's just start with the fundamentals. I think people understand probability the best, so let's start there. You should be able to calculate the odds, the probability, and the odds ratio. So I want to look at another example. I'm going to use this CAFE data set to illustrate the logit function in R. So this data set has information about the vote of 50 Democrats and 49 Republicans, and this is for the 11th Amendment on the corporate average fuel economy standard for cars and trucks. So in this data set, there's a binary response variable, one if they voted for the amendment, a zero if they voted against the amendment. We have a binary independent variable, their political affiliation, one if the senator is a Republican and zero if they're a Democrat. Then we have this amount variable, and this is the lifetime total contributions made from the auto industry. We're going to transform this by taking the natural log because of some outliers. Note that I took this from a paper, I'm replicating the study in precedence paper, the citations in the PowerPoint slide, and I just want you to know that I'm just going to take a natural log for the transformation, but in the paper, he uses this transformation of taking log base 10 instead of the natural log, and he multiplies it by 10. Takes the amount, multiplies by 10, and then that gives you an understanding of how many figures are in the dollar amounts. So if it's $1,000, it has four figures, the number of digits. He argues in his paper that it's one way of being able to get a handle on interpretation, but I think the math is a little tricky so I'm just going to the natural log for now. The results are virtually identical as we shall see.