शुरू करेंमुफ़्त में शुरू करें

Bounded predictions

The glm() function is used because you need a response function that bounds the model predictions between zero and one. Let's illustrate this effect in a graph. But this time you need to draw a curve (instead of a straight line)!

You start with plotting the relation HOPPINESS ~ price.ratio. You can add the logistic function to the plot by using curve(). The curve() function is used to evaluate another function at x data points. Here, this function is predict()! The predict() function retrieves the coefficients of the logistic.model to make predictions about some values provided in a data frame object. The trick is to set price.ratio = x in the data.frame argument. This fits a curve through the predicted data values.

यह अभ्यास पाठ्यक्रम का हिस्सा है

Building Response Models in R

पाठ्यक्रम देखें

अभ्यास निर्देश

  • Display the relation between HOPPINESS and price.ratio by using the function plot().
  • Obtain the purchase probabilities for Hoppiness by applying the function predict() on the logistic.model with price.ratio in the data frame argument.
  • Fit a curve through the predicted data values by using the function curve().

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Plot HOPPINESS against price.ratio
___(___, data = choice.data)

# Add the logistic response function
___(___(___, data.frame(___), type = "response"), add = TRUE)
कोड संपादित करें और चलाएँ