lm_plot: Density plot for a given lm model with one binary covariate.

Description Usage Arguments Details Examples

View source: R/plot-pmtree.R

Description

Can be used on its own but is also useable as plotfun in node_pmterminal.

Usage

1
2
lm_plot(mod, data = NULL, densest = FALSE, theme = theme_classic(),
  yrange = NULL)

Arguments

mod

A model of class lm.

data

optional data frame. If NULL the data stored in mod is used.

densest

should additional to the model density kernel density estimates (see geom_density) be computed?

theme

A ggplot2 theme.

yrange

Range of the y variable to be used for plotting. If NULL the range in the data will be used.

Details

In case of an offset, the value of the offset variable will be set to the median of the values in the data.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## example taken from ?lm
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2, 10, 20, labels = c("Ctl","Trt"))
weight <- c(ctl, trt)
data <- data.frame(weight, group)
lm.D9 <- lm(weight ~ group, data = data)
lm_plot(lm.D9)

## example taken from ?glm (modified version)
data(anorexia, package = "MASS")
anorexia$treatment <- factor(anorexia$Treat != "Cont")
anorex.1 <- glm(Postwt ~ treatment + offset(Prewt),
                family = gaussian, data = anorexia)
lm_plot(anorex.1)

model4you documentation built on Dec. 6, 2019, 3 p.m.