# Video: Modeling Data Using Logistic Regression

Some data sets can be modeled with nonlinear regression models. Which scatterplot shows data that can be best modeled by logistic regression? Which formula models the relationship between 𝑥 and 𝑦 in such a data set? [A] 𝑦 = 𝑐/(1 − 𝑎𝑒)^(𝑏𝑥) [B] 𝑦 = 𝑐/(1 − 𝑎𝑒)^(−𝑏𝑥) [C] 𝑦 = 𝑐/(1 + 𝑎𝑒)^(𝑏𝑥) [D] 𝑦 = 𝑐/(1 + 𝑎𝑒)^(−𝑏𝑥)

08:57

### Video Transcript

Some data sets can be modeled with a nonlinear regression models. The first part of the question asks us which scatterplot shows data that can be best modelled by logistic regression? Is it scatterplot A), B), C), or D)? The second part of the question asks us which formula models the relationship between 𝑥 and 𝑦 in such a data set? Is it option A) 𝑦 equals 𝑐 over one minus 𝑎𝑒 to the 𝑏𝑥? Option B) 𝑦 equals 𝑐 over one minus 𝑎𝑒 to the negative 𝑏𝑥? Option C) 𝑦 equals 𝑐 over one plus 𝑎𝑒 to the 𝑏𝑥? Or option D) 𝑦 equals 𝑐 over one plus 𝑎𝑒 to the negative 𝑏𝑥?

Let’s start with the first part of the question, which scatterplot shows data that can be best modelled by logistic regression? For logistic regression to be suitable for a particular data set, that data should fall in a very distinctive shape when plotted on a scatter plot. We can see this very distinctive shape in option D. This shape is sometimes called an S-shape because the data tends to fall on or near a curve which has a somewhat slanted S-shape.

The characteristics of a logistic curve, for which logistic regression is named, are as follows. A logistic curve has a shallow slope which increases before plattering out again. Option D is the only option which displays these characteristics.

We can draw a nice smooth curve through or near the data points for option B. But while this curve starts off shallow and gets steeper as we’d like it to for a regression curve, it’s never plattered out again. And we need the slope to become a shallower and the curve to platter out for logistic regression to be suitable. The data in option B, therefore, isn’t particularly suitable to be modelled by logistic regression.

For options A and C, it’s pretty hard to draw a nice smooth curve through or near the data points. But certainly, we don’t see a shallow slope becoming steeper before plattering out again. Option D is the only one that makes sense.

Now we move on to the second part of our question, which formula models the relationship between 𝑥 and 𝑦 in such a data set? All the options have the same form. The question is whether there’s a plus or a minus after the one in the denominator, and whether there is a minus sign before 𝑏𝑥 in the exponent.

Of course, if A and B are allowed to be negative, then all of these formulas are equivalent. We can get formula A from formula B by changing the value of B to its additive inverse, or opposite. We, therefore, assume that both A and B are positive. And that these options are showing us the form of the formula that we expect to see.

To decide which option is correct, it helps to look at the previous part of the question and to extend the curve we’ve drawn in both directions. We can see that as 𝑥 approaches negative ∞, we want 𝑦 to decrease, getting closer and closer to zero. 𝑦 tends to zero as 𝑥 tends to negative ∞. Looking at the other end of the curve, we see that as 𝑥 approaches positive ∞, we want 𝑦 to asymptotically approach sum finite value. So, 𝑦 tends to this finite value 𝑘 as 𝑥 approaches ∞.

We can use these facts to choose between our options. But first we need to clear some room, so we have space to work. Let’s try option A first. Does 𝑦 equals 𝑐 over one minus 𝑎𝑒 to the 𝑏𝑥 tend to zero as 𝑥 tends to negative ∞ as we would like? Well, for this fraction to tend to zero, as the numerator 𝑐 is unchanging, the denominator will have to tend to plus or minus ∞. And does it?

No, it doesn’t. And as 𝑥 tends negative ∞, 𝑒 to the 𝑏𝑥 tends to zero. This is because we said that 𝑏 is greater than zero. Similarly, 𝑎 times 𝑒 to the 𝑏𝑥 will tend to zero, as well negative 𝑎𝑒 to the 𝑏𝑥. And so, one minus 𝑎𝑒 to the 𝑏𝑥 will tend to one, not plus or minus ∞ as we require. We can, therefore, eliminate options A, as in this case, 𝑦 does not tend to zero as 𝑥 tends to negative ∞.

If we replace the minus sign in the denominator with a plus sign, we find that one plus 𝑎 to the 𝑏𝑥 also tends to one, as 𝑥 tends to negative ∞. And for this reason, we can also eliminate option C, 𝑦 equals 𝑐 over one plus 𝑎𝑒 to the 𝑏𝑥. As it doesn’t tend to zero as 𝑥 tends to negative ∞. Let’s move on to option B.

We ask if option B, 𝑦 equals 𝑐 over one minus 𝑎𝑒 to the negative 𝑏𝑥, tend to zero as 𝑥 tends to negative ∞. And for this to happen, the denominator one minus 𝑎𝑒 to the negative 𝑏𝑥 must tend to either plus or minus ∞ as 𝑥 tends to negative ∞. In this case, the answer is yes. As 𝑥 tends to negative ∞, negative 𝑏𝑥 tends to ∞. This is because 𝑏 is greater than zero. And so, each of the negative 𝑏𝑥 will tend to ∞, as will 𝑎𝑒 to the negative 𝑏𝑥, as 𝑎 is greater than zero.

However, negative 𝑎𝑒 to the negative 𝑏𝑥 will tend to negative ∞. And adding one to this doesn’t do much to change this. One minus 𝑎𝑒 to the negative 𝑏𝑥 also tends to negative ∞ as 𝑥 tends to negative ∞. So, the denominator of our fraction tends to negative ∞ as 𝑥 tends to negative ∞. And so, our fraction itself tends to zero, as 𝑥 tends to negative ∞ as we wish.

But before we get too excited, let’s just stop and think. The denominator of this fraction for 𝑦 tends to negative ∞, so it’s negative. And as you imagined that the numerator of our fraction for 𝑦, which is 𝑐, is positive, much like A and B. The value of 𝑦, which is 𝑐 over something negative, will be negative. 𝑦 is negative and approaching zero from below. This isn’t what we see in our diagram. Something strange is going on and you might like to use graphing software to explore what. But it looks like option B is out of the running.

In option D, the minus sign of the one in the denominator becomes a plus sign. And we ask if one plus 𝑎𝑒 to the negative 𝑏𝑥 tends to plus or minus ∞. Again, the answer is yes, but plus 𝑎𝑒 to the negative 𝑏𝑥 tends to plus ∞. And one plus 𝑎𝑒 to the negative 𝑏𝑥 does also. And so, one plus 𝑎𝑒 to the negative 𝑏𝑥 is greater than zero. And it turns out that this is not true for suitably small 𝑥, it’s true for all 𝑋.

This means that 𝑦 is positive as we want and expect. So, we have no such problem with option D, which is good news because we’ve eliminated all the other options. Option D is, therefore, our answer. You might notice that we haven’t checked that 𝑦 tends to some constant value 𝑘 as 𝑥 tends to ∞. We don’t need to check this, as we already found our answer by a process of elimination.

But if you do check this, then you’ll find that 𝑘 is, in fact, the value 𝑐, the numerator of our fraction. This also justifies the previous assumption that 𝑐 should be positive like 𝑎 and 𝑏. We use this assumption to show that 𝑦 would be less than zero for suitably small 𝑥 in option B. This formula 𝑦 equals 𝑐 over one plus 𝑎𝑒 to the negative 𝑏𝑥 for logistic regression is well-worth remembering. As we’ve just seen it’s not particularly easy to work this formula out using logic alone.