Press "Enter" to skip to content

Building a 3D Regression Plane with a Scatter Plot in R

Sebastian Sauer embraces the third dimension:

Here’s the linear model with 2 predictors, giving us a model that can be visualized in 3D:

lm1 <- lm(mpg ~ hp + disp, data = mtcars)

As is standard, we’ll predict mpg.

Click through for a simple implementation using plotly.