Learn R Programming

coefplot (version 1.1.8)

multiplot: Plot multiple coefplots

Description

Plot the coeffcients from multiple models

Usage

multiplot(..., title = "Coefficient Plot",
    xlab = "Value", ylab = "Coefficient", innerCI = 1,
    outerCI = 2, lwdInner = 1, lwdOuter = 0,
    color = "blue", cex = 0.8, textAngle = 0,
    numberAngle = 90, zeroColor = "grey", zeroLWD = 1,
    zeroType = 2, single = TRUE, scales = "fixed",
    ncol = length(unique(modelCI$Model)),
    sort = c("natural", "normal", "magnitude", "size", "alphabetical"),
    decreasing = FALSE, names = NULL, numeric = FALSE,
    fillColor = "grey", alpha = 1/2, horizontal = FALSE,
    factors = NULL, only = NULL, shorten = TRUE,
    intercept = TRUE, plot = TRUE, drop = FALSE)

Arguments

...
Models to be plotted
title
The name of the plot, if NULL then no name is given
xlab
The x label
ylab
The y label
innerCI
How wide the inner confidence interval should be, normally 1 standard deviation. If 0, then there will be no inner confidence interval.
outerCI
How wide the outer confidence interval should be, normally 2 standard deviations. If 0, then there will be no outer confidence interval.
lwdInner
The thickness of the inner confidence interval
lwdOuter
The thickness of the outer confidence interval
color
The color of the points and lines
cex
The text size multiplier, currently not used
textAngle
The angle for the coefficient labels, 0 is horizontal
numberAngle
The angle for the value labels, 0 is horizontal
zeroColor
The color of the line indicating 0
zeroLWD
The thickness of the 0 line
zeroType
The type of 0 line, 0 will mean no line
single
logical; If TRUE there will be one plot with the points and bars stacked, otherwise the models will be displayed in seperate facets
scales
The way the axes should be treated in a faceted plot. Can be c("fixed", "free", "free_x", "free_y")
ncol
The number of columns that the models should be plotted in
sort
Determines the sort order of the coefficients. Possible values are c("natural", "normal", "magnitude", "size", "alphabetical")
decreasing
logical; Whether the coefficients should be ascending or descending
names
Names for models, if NULL then they will be numerically labelled
numeric
logical; If true and factors has exactly one value, then it is displayed in a horizontal graph with constinuous confidence bounds.
fillColor
The color of the confidence bounds for a numeric factor
alpha
The transparency level of the numeric factor's confidence bound
horizontal
logical; If the plot should be displayed horizontally
intercept
logical; Whether the Intercept coefficient should be plotted
plot
logical; If the plot should be drawn, if false then a data.frame of the values will be returned
factors
Vector of factor variables that will be the only ones shown
only
logical; If factors has a value this determines how interactions are treated. True means just that variable will be shown and not its interactions. False means interactions will be included.
shorten
logical or character; If FALSE then coefficients for factor levels will include their variable name. If TRUE coefficients for factor levels will be stripped of their variable names. If a character vector of variable
drop
logical; if TRUE then models without valid coeffiecients to show will not be plotted

Value

  • A ggplot object

Details

Plots a graph similar to coefplot but for multiple plots at once. For now, if names is provided the plots will appear in alphabetical order of the names. This wil be adjusted in future iterations.

See Also

link{coefplot}

Examples

Run this code
data(diamonds)
model1 <- lm(price ~ carat + cut, data=diamonds)
model2 <- lm(price ~ carat + cut + color, data=diamonds)
model3 <- lm(price ~ carat + color, data=diamonds)
multiplot(model1, model2, model3)
multiplot(model1, model2, model3, single=FALSE)
multiplot(model1, model2, model3, factors="color")
multiplot(model1, model2, model3, factors="color", drop=TRUE)
multiplot(model1, model2, model3, plot=FALSE)

Run the code above in your browser using DataLab