In this recipe, we will see how we can visualize a three-dimensional scatter plot with a fitted regression plane.
Let's recall the airquality
data from the datasets library. In this particular recipe, we will use Ozone
as a dependent variable and Solar.R
and Temp
as independent variables in order to fit the regression model, and then we visualized it.
To produce this plot, we will perform the following steps:
attach()
function.Ozone
as a dependent variable and Solar.R
and Temp
as independent variables and store it as an R object. This regression model estimated the linear regression coefficient of the independent variables in relation to the dependent variable.Here is the R code that performs the preceding steps:
attach(airquality) s3dplot<- scatterplot3d(Temp,Solar.R,Ozone) model <- lm(Ozone~Solar.R+Temp) s3dplot$plane3d(model)
18.191.103.117