My question is naive but I try to understand something : I have some 3D points and I want to compute the plane which fit to my data 3D points with R.
library(scatterplot3d)
x<-sample(1:100, 100)
y<-sample(1:100, 100)
z<-sample(1:100, 100)
xyz <- cbind(x,y,z)
s3d <- scatterplot3d(xyz, type="p", highlight.3d=TRUE, angle=55, scale.y=0.7, pch=16, main="test xyz")
# regression plane
reg <- lm(x ~ y + z)
summary(my.lm)
it returns :
Call:
lm(formula = x ~ y + z)
Residuals:
Min 1Q Median 3Q Max
-51.085 -22.956 -0.801 23.806 51.610
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 47.34428 8.28049 5.718 1.19e-07 ***
y 0.11647 0.10163 1.146 0.255
z -0.05398 0.10163 -0.531 0.597
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 29.04 on 97 degrees of freedom
Multiple R-squared: 0.01826, Adjusted R-squared: -0.001985
F-statistic: 0.9019 on 2 and 97 DF, p-value: 0.4092
Finally I plot the plane :
s3d$plane3d(47.34428, 0.11647, -0.05398, lty.box = "solid") #or s3d$plane3d(reg, lty.box = "solid")
But I don't know/understand how plane3d can generate the equation of the plane from these 3 values... I tried with the rgl.planes3d()
(parameters are a, b, c and d, the value of the equation ax+by+cz+d=0) and the plane is not what I expected...
Could someone help me ?