Average marginal effects
The logistic response function is essentially nonlinear. Therefore, it is not immediately clear what is the effect of a unit change in the price ratio on the probability that a customer purchases Hoppiness. A solution is to interpret the effect of a unit change averaged over all customers.
This average marginal effect can be derived by using the function margins(). The function is loaded from the add-on package margins. Finally, you will compare the average marginal effect for price.ratio of the logistic.model to the price.ratio coefficient of the probability.model.
Diese Übung ist Teil des Kurses
Building Response Models in R
Anleitung zur Übung
- Load the add-on package
marginsby using the functionlibrary(). - Obtain the
price.ratiocoefficient for theprobability.modelby using the functioncoef(). - Obtain the marginal effect for
price.ratioof thelogistic.modelby using the functionmargins().
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Load the margins package
# Linear probability model
# Logistic model