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

Methods for trend lines

During the previous exercise, you used ggplot2's default geom_smooth(). During this exercise, you will use a glm() instead. This will allow you to "see" a logistic regression with ggplot2. Specifically, you plot the probability someone takes the bus given their commute distance.

You will need to tell geom_smooth() to use the glm() method. Recall from Chapter 2 that the default family for a glm() is a Gaussian family, which produces the same results as a lm(). Thus, you will also need to specify the method argument from glm().
The code for creating gg_jitter, which you built in the last exercise, has been provided for you.

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

Generalized Linear Models in R

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

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

  • Use the "glm" method with geom_smooth().
  • With the method.args, set the family to 'binomial'.

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

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

# Create a jittered plot of MilesOneWay vs Bus2 using the bus dataset
gg_jitter <- ggplot(data = bus, aes(x = MilesOneWay, y = Bus2)) + 
	geom_jitter(width = 0, height = 0.05) +
	ylab("Probability of riding the bus") +
	xlab("One-way commute trip (in miles)")

# Add a geom_smooth() that uses a GLM method to your plot
gg_jitter + geom_smooth(method =  ___ , method.args = list(___))
कोड संपादित करें और चलाएँ