ggPredict: Visualize predictions from the multiple regression models.

View source: R/ggPredict.R

ggPredictR Documentation

Visualize predictions from the multiple regression models.

Description

Visualize predictions from the multiple regression models.

Usage

ggPredict(
  fit,
  pred = NULL,
  modx = NULL,
  mod2 = NULL,
  modx.values = NULL,
  mod2.values = NULL,
  dep = NULL,
  mode = 1,
  colorn = 3,
  maxylev = 6,
  show.point = getOption("ggPredict.show.point", TRUE),
  show.error = FALSE,
  error.color = "red",
  jitter = NULL,
  se = FALSE,
  alpha = 0.1,
  show.text = TRUE,
  add.modx.values = TRUE,
  add.loess = FALSE,
  labels = NULL,
  angle = NULL,
  xpos = NULL,
  vjust = NULL,
  digits = 2,
  facet.modx = FALSE,
  facetbycol = TRUE,
  plot = TRUE,
  summarymode = 1,
  ...
)

Arguments

fit

An object of class "lm" or "glm"

pred

The name of predictor variable

modx

Optional. The name of moderator variable

mod2

Optional. The name of second moderator variable

modx.values

For which values of the moderator should lines be plotted? Default is NULL. If NULL, then the customary +/- 1 standard deviation from the mean as well as the mean itself are used for continuous moderators. If the moderator is a factor variable and modx.values is NULL, each level of the factor is included.

mod2.values

For which values of the second moderator should lines be plotted? Default is NULL. If NULL, then the customary +/- 1 standard deviation from the mean as well as the mean itself are used for continuous moderators. If the moderator is a factor variable and modx.values is NULL, each level of the factor is included.

dep

Optional. The name of dependent variable

mode

A numeric. Useful when the variables are numeric. If 1, c(-1,0,1)*sd + mean is used. If 2, the 14th, 50th, 86th percentile values used. If 3 sequence over a the range of a vector used

colorn

The number of regression lines when the modifier variable(s) are numeric.

maxylev

An integer indicating the maximum number of levels of numeric variable be treated as a categorical variable

show.point

Logical. Whether or not add points

show.error

Logical. Whether or not show error

error.color

color of error. dafault value is "red"

jitter

logical Whether or not use geom_jitter

se

Logical. Whether or not add confidence interval

alpha

A numeric. Transparency

show.text

Logical. Whether or not add regression equation as label

add.modx.values

Logical. Whether or not add moderator values to regression equation

add.loess

Logical. Whether or not add loess line

labels

labels on regression lines

angle

angle of text

xpos

x axis position of label

vjust

vertical alignment of labels

digits

integer indicating the number of decimal places

facet.modx

Create separate panels for each level of the moderator? Default is FALSE

facetbycol

Logical.

plot

Logical. Should a plot of the results be printed? Default is TRUE.

summarymode

An integer indicating method of extracting typical value of variables. If 1, typical() is used.If 2, mean() is used.

...

additional arguments to be passed to geom_text

Examples

fit=loess(mpg~hp*wt*am,data=mtcars)
ggPredict(fit)
ggPredict(fit,hp)
## Not run: 
ggPredict(fit,hp,wt)
fit=lm(mpg~wt*hp-1,data=mtcars)
ggPredict(fit,xpos=0.7)
fit=lm(mpg~hp*wt,data=mtcars)
ggPredict(fit)
ggPredict(fit,labels=paste0("label",1:3),xpos=c(0.3,0.6,0.4))
ggPredict(fit,se=TRUE)
ggPredict(fit,mode=3,colorn=40,show.text=FALSE)
fit=lm(log(mpg)~hp*wt,data=mtcars)
ggPredict(fit,dep=mpg)
fit=lm(mpg~hp*wt*cyl,data=mtcars)
ggPredict(fit,modx=wt,modx.values=c(2,3,4,5),mod2=cyl,show.text=FALSE)
ggPredict(fit,hp,wt,show.point=FALSE,se=TRUE,xpos=0.5)
ggPredict(fit,modx=wt,xpos=0.3)
ggPredict(fit)
mtcars$engine=ifelse(mtcars$vs==0,"V-shaped","straight")
fit=lm(mpg~wt*engine,data=mtcars)
ggPredict(fit)
require(TH.data)
fit=glm(cens~pnodes*horTh,data=GBSG2,family=binomial)
ggPredict(fit,pnodes,horTh,se=TRUE,xpos=c(0.6,0.3),angle=c(40,60),vjust=c(2,-0.5))
fit1=glm(cens~pnodes,data=GBSG2,family=binomial)
ggPredict(fit1,vjust=1.5,angle=45)
fit3=glm(cens~pnodes*age,data=GBSG2,family=binomial)
ggPredict(fit3,pred=pnodes,modx=age,mode=3,colorn=10,show.text=FALSE)
fit2=glm(cens~pnodes*age*horTh,data=GBSG2,family=binomial)
ggPredict(fit2,pred=pnodes,modx=age,mod2=horTh,mode=3,colorn=10,show.text=FALSE)
fit=lm(mpg~log(hp)*wt,data=mtcars)
ggPredict(fit,hp,wt)
fit=lm(mpg~hp*wt+disp+gear+carb+am,data=mtcars)
ggPredict(fit,disp,gear,am)
library(moonBook)
fit=lm(weight~I(height^3)+I(height^2)+height+sex,data=radial)
ggPredict(fit)
predict3d(fit)

## End(Not run)

predict3d documentation built on April 14, 2023, 12:26 a.m.