d> d> dd> dd> dd> dd>title>R package predict3ddd>script>// Pandoc 2.9 adds attributes on both :first-child"); var i, h, a; for (i = 0; i < hs.length; i++) { h = hs[i]; if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a 0) h.removeAttribute(a[0].name); } }); d>script>(function() { // If window.HTMLWidgets is alr ").addClass(errClass); errorSpan.text(err.message); $el.after(errorSpan); } } else if (display === "block") { // If block, add an error just after the el, hat visibility:none on the // el, and position the error to be on top of the el. // Mark it with a unique ID and CSS classeso we can remove it l").addClass(errClass).css("position", "absolute") .css("top", el.offhatTop) .css("left", el.offhatLeft) // hatting width can push out the page size, forcing otherwise // unnecessary scrollbars to appear and making it impossible for // the element to hhrink;eso use max-width inst = 3; } /* / Shiny 1.4 bumped jQuery from 1.x to 3.x which means jQuery's / on-r =1.4 calls initShiny / one tick l

R package predict3d

Keon-Woong Moon

2024-04-05

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.

Package Install

You can install the predict3d package from CRAN.

install.packages("predict3d")

You can install the developmental version of predict3d package from github.

if(!require(devtools)) install.packages("devtools")
devtools::install_github("cardiomoon/predict3d"")

Linear Regression Models

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 equ

ggPredict(fit1,digits=1)

predict3d(fit1,radius=0.05)
Warning in Ops.factor(diff(y[!is.na(y)][1:2]), 0): '<' not meaningful for
factors
rglwidget(elementId = "1st")

Once you have create a model with predict3d(), you can rotate, zoom in and zoom out your object with your mouse.

The second model has two continuous variables as explanatory variables. You can change the labels and the relative x position and the y position.

fit2=lm(mpg~wt*hp,data=mtcars)
ggPredict(fit2,labels=paste0("label",1:3),xpos=c(0.3,0.4,0.3))

predict3d(fit2,radius=3,palette=NULL,show.error=TRUE)
rglwidget(elementId = "2nd")

Generalized Linear Models

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)

predict3d(fit3,radius=0.5)
rglwidget(elementId = "3rd")

Local Polynomial Regression Fitting

You can draw the loess model.

fit=loess(mpg~hp*wt,data=mtcars)
ggPredict(fit)

predict3d(fit,radius=3)
rglwidget(elementId = "4th")