Parameter estimates are plotted along with error bars indicating 95 pct confidence intervals.
One or more models. Currently,
Logical indicating whether the intercept should be plotted (defaults
Which model parameters to plot estimates for, given as character strings.
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.
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
$coefficients slot from the model object and
confidence intervals are computed by calling
plotEst supports all models that have a
coefficents slot and a
No return values; called for side effects.
Anne Helby Petersen
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"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.