R package predict3d
aims to draw predicts plot for various regression models. The main two functions are ggPredict() for 2-dimensional plot and predict3d() for 3-dimensional plot.
You can install predict3d
package from CRAN.
You can install the developmental version of predict3d
package from github.
if(!require(devtools)) install.packages("devtools")
devtools::install_github("cardiomoon/predict3d"")
You can draw linear regression models. First model has one categorical and one continuous explanatory variables.
require(predict3d)
require(rgl)
fit1=lm(Sepal.Length~Sepal.Width*Species,data=iris)
fit1
Call:
lm(formula = Sepal.Length ~ Sepal.Width * Species, data = iris)
Coefficients:
(Intercept) Sepal.Width
2.6390 0.6905
Speciesversicolor Speciesvirginica
0.9007 1.2678
Sepal.Width:Speciesversicolor Sepal.Width:Speciesvirginica
0.1746 0.2110
You can draw plot for this model. ggPredict() function draws a scatterplot with regression line and shows regression equations parallel to the regression lines.
You can see the live 3d plot at http://rpubs.com/cardiomoon/471347.
The second model has two continuous variables as explanatory variables. You can change the labels and the relative x position and the y position.
You can draw generalized linear models.
require(TH.data)
fit3=glm(cens~pnodes*age*horTh,data=GBSG2,family=binomial)
ggPredict(fit3,se=TRUE,show.text = FALSE)
You can draw the loess model.
Once you have create a model with predict3d(), you can move your object with your mouse or R codes. For example, You can rotate you object with this R codes.
start <- proc.time()[3]
while ((i <- 36*(proc.time()[3] - start)) < 360) {
view3d(i, i/4);
}
play3d(spin3d(axis = c(1, 0, 0), rpm = 30), duration = 2)
You can save your 3d plot as a figure file or pdf file.
For more information about package rgl
, please read the package vignette at: https://CRAN.R-project.org/package=rgl/vignettes/rgl.html
You can see the following vignettes published on rpubs.com