plotEst: Plot parameter estimates with 95 pct confidence intervals.

Description Usage Arguments Details Value Author(s) Examples

View source: R/plotEst.R

Description

Parameter estimates are plotted along with error bars indicating 95 pct confidence intervals.

Usage

1
plotEst(..., intercept = TRUE, par = NULL, colors = NULL)

Arguments

...

One or more models. Currently, lm, glm, geeglm, geelm, and mice models are supported, but other model types may be applicable as well, see details.

intercept

Logical indicating whether the intercept should be plotted (defaults to TRUE).

par

Which model parameters to plot estimates for, given as character strings. Default is NULL which means that all parameter estimates are plotted.

colors

Color scale to use if several models are plotted. Defaults to a color blind friendly scale. If there are more models than there are colors, the color values are repeated.

Details

One or more models can be supplied, and if the parameters have the same names across models, they will be grouped together allowing for easy comparison.

Note that models can be given with or without names. If names are supplied (see example below), these are printed in the plot legend. Otherwise, the name of the model object is printed there instead.

Implementation details: As a default, the estimates are extracted from the $coefficients slot from the model object and confidence intervals are computed by calling confint(). This means that plotEst supports all models that have a coefficents slot and a confint method.

Value

No return values; called for side effects.

Author(s)

Anne Helby Petersen

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Fit example models
data(iris)
m1 <- lm(Sepal.Length ~ Petal.Length, iris)
m2 <- lm(Sepal.Length ~ Petal.Length + Petal.Width, iris)

# Plot one model
plotEst(m2)

# Plot two models with default model labels
plotEst(m1, m2)

# Plot two models with custom model labels (simple)
plotEst(model1 = m1, model2 = m2)

# Plot two models with custom model labels (with spacing)
plotEst(`Simple model` = m1, `Full petal model` = m2)

# Plot two models without intercept
plotEst(m1, m2, intercept = FALSE)

# Plot two models with custom parameter subset
plotEst(m1, m2, par = c("Petal.Length"))

# Plot two models with custom color scale given by color names
plotEst(m1, m2, colors = c("red", "blue"))

# Plot two models with custom color scale given by color hex codes
#  note: only the first colors are used as there are more 
#  colors than models
plotEst(m1, m2, colors = c("#CC6666", "#9999CC", "#66CC99"))

geeasy documentation built on Jan. 6, 2022, 5:09 p.m.