mod_plot: Plot out model values

Description Usage Arguments Examples

Description

Plot out model values

Usage

1
2
3
4
mod_plot(model = NULL, formula = NULL, data = NULL, bootstrap = 0,
  nlevels = 3, at = list(), class_level = NULL, interval = c("none",
  "confidence", "prediction"), post_transform = NULL, size = 1,
  alpha = 0.8, ...)

Arguments

model

the model to display graphically. Can also be an ensemble produced with mod_ensemble()

formula

setting the y ~ x + color variables

data

optional data set from which to extract levels for explanatory variables

bootstrap

when > 1, this will generate bootstrap replications of the model and plot all of them. Use as an alternative to interval for confidence intervals.

nlevels

how many levels to display for those variables shown at discrete levels

at

named list giving specific values at which to hold the variables. You can accomplish this without forming a list by using .... See examples.

class_level

character string. If a probability for a classifier is being shown, which levels of the response variable to use in the plot. (Default: the first one.)

interval

show confidence or prediction intervals: values "none", "confidence", "prediction"

post_transform

a scalar transformation and new name for the response variable, e.g. post_transform = c(price = exp) to undo a log transformation of price.

size

numerical value for line width (default: 1)

alpha

numerical value in 0 to 1 for transparency (default: 0.8)

...

specific values for explantory variables

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 
mod1 <- lm(wage ~ age * sex + sector, data = mosaicData::CPS85)
mod_plot(mod1)
mod_plot(mod1, n = Inf, interval = "confidence") 
mod_plot(mod1, ~ sector + sex + age) # not necessarily a good ordering
mod_plot(mod1, ~ age + sex + sector, nlevels = 8) 
mod2 <- lm(log(wage) ~ age + sex + sector, data = mosaicData::CPS85)
mod_plot(mod2, post_transform = c(wage = exp), 
     interval = "confidence") # undo the log in the display
mod3 <- glm(married == "Married" ~ age + sex * sector,
            data = mosaicData::CPS85, family = "binomial")
mod_plot(mod3)
E3 <- mod_ensemble(mod3, 10)
mod_plot(E3)
mod4 <- rpart::rpart(sector ~ age + sex + married, data = mosaicData::CPS85)
mod_plot(mod4)
mod_plot(mod4, class_level = "manag")
mod5 <- randomForest::randomForest(
         sector ~ age + sex + married, data = mosaicData::CPS85)
mod_plot(mod5)
mod_plot(mod5, class_level = "manag")

## End(Not run)

mosaicModel documentation built on May 2, 2019, 7:59 a.m.