Session Ready
Exercise

A plane in 3D

One reason that many people go to a restaurant—apart from the food—is that they don't have to cook or clean up. Many people appreciate the experience of being waited upon, and we can all agree that the quality of the service at restaurants varies widely. Are people willing to pay more for better restaurant Service? More interestingly, are they willing to pay more for better service, after controlling for the quality of the food?

Multiple regression gives us a way to reason about these questions. Fit the model with Food and Service and interpret the coefficients and fit. Did the coefficient on Food change from the previous model? What do the coefficients on Food and Service tell you about how these restaurants set prices?

Next, let's visually assess our model using plotly. The x and y vectors, as well as the plane matrix, have been created for you.

Instructions
100 XP
  • Use lm() to fit a multiple regression model for Price as a function of Food and Service.
  • Use plot_ly to draw 3D scatterplot for Price as a function of Food and Service by mapping the z variable to the response and the x and y variables to the explanatory variables. Place the food quality on the x-axis and service rating on the y-axis.
  • Use add_surface() to draw a plane through the cloud of points using the object plane.