Get startedGet started for free

Logistic response models

1. Logistic response models

Although the form of the prediction equation for the linear probability model appears to be reasonable, the model itself did not describe the purchase probabilities well.

2. Logistic response function

Since the decision to purchase is interpreted as the probability that the customer purchases the product, it's predicted value should be bounded between zero and one. In the linear probability model, the predicted values are not guaranteed to be within the zero and one range. As a result, the model can lead to model predictions which are outside the zero-one range. Purchase probabilities are more appropriately described by assuming some curved relationship between the response and predictor. One such curved relationship is given by the logistic response function.

3. A logistic model for beer demand

R makes it easy to fit a response model with a logistic response function. The function to be called is glm() - for generalized linear model - and the function’s argument list is not so different from the one used in the linear model function. The relationship between the purchases and the price-dot-ratio predictor is described via the symbolic formula argument. Since the outcome to predict - can only take on the values zero or one - we additionally specify the argument 'family equals binomial'. The estimated price coefficient is again negative meaning: increasing price.ratios are associated with lower purchase probabilities for HOPPINESS.

4. Bounded predictions

Next, we display the relation between the purchase probabilities for HOPPINESS and the price-dot-ratio by using the function plot(). To investigate the predicted purchase probabilities produced by the logistic response model, we use the function predict(). The predict function produces the predicted purchase probabilities - given price-dot-ratio - by evaluating the fitted coefficients of the logistic-dot-model. To obtain predictions on the scale of the response variable - which are the predicted purchase probabilities - we set the additional type argument to "response". To finally add the corresponding logistic response function to the graph, we apply the function curve() on the predicted probabilities. The model does fit the data much better than before as the logistic response function restricts the model predictions to be in the zero-one range.

5. Average marginal effects

As the logistic function is a nonlinear function, it is not immediately clear - what is the effect of a price-dot-ratio unit change - on the probability that a customer purchases HOPPINESS. A solution is to derive the effect of a one unit increase for each customer and then average the effect over all customers. This marginal effect reflects, on average, how likely a purchase is for a price-dot-ratio unit change. The average marginal effects for the logistic.model can be derived by using the function margins() from the add-on package margins. The average marginal effects are compared to the coefficients from the previously estimated probability-dot-model. For the logistic model, the purchase probability decreases on average around 45 percent for a unit increase in the price-dot-ratio. This effect is now similar in size to the coefficient obtained from the linear probability model.

6. Effect plots

To better understand the concept of average marginal effects - we obtain a graph of the marginal effect of price-dot-ratio by using the function cplot() from the margins package. We calculate the marginal effects of price-dot-ratio for values ranging from -1-point-25 to 1-point-25 with a step size of 0-point-25. The resulting graph shows how the probability of purchasing HOPPINESS decreases when the price-dot-ratio increases. For a price ratio increase from -1-point-25 to -1 - the purchase probability decreases to 95%. For an increase from -1 to -0-point-75 it decreases further to 80%. Meaning: the magnitude of the change in purchase probabilities is not the same for a constant unit change.

7. Let's practice!

Great! Now let’s use the logistic model in practice.