plotreg | R Documentation |
Create coefficient plots of R regression output using ggplot2.
plotreg(
l,
file = NULL,
custom.model.names = NULL,
custom.title = NULL,
custom.coef.names = NULL,
custom.coef.map = NULL,
custom.note = NULL,
override.coef = 0,
override.se = 0,
override.pval = 0,
override.ci.low = 0,
override.ci.up = 0,
override.pvalues = 0,
omit.coef = NULL,
reorder.coef = NULL,
ci.level = 0.95,
ci.force = FALSE,
ci.force.level = 0.95,
ci.test = 0,
type = "facet",
theme = NULL,
signif.light = "#FBC9B9",
signif.medium = "#F7523A",
signif.dark = "#BD0017",
insignif.light = "#C5DBE9",
insignif.medium = "#5A9ECC",
insignif.dark = "#1C5BA6",
...
)
l |
A statistical model or a list of statistical models. Lists of
models can be specified as |
file |
Using this argument, the resulting table is written to a file
rather than to the R prompt. The file name can be specified as a character
string. Writing a table to a file can be useful for working with MS Office
or LibreOffice. For example, using the |
custom.model.names |
A character vector of labels for the models. By
default, the models are named "Model 1", "Model 2", etc. Specifying
|
custom.title |
With this argument, a replacement text for the
|
custom.coef.names |
By default, texreg uses the coefficient names
which are stored in the models. The Sometimes it happens that the same variable has a different name in different models. In this case, the user can use this function to assign identical names. If possible, the rows will then be merged into a single row unless both rows contain values in the same column. Where the argument contains an See also |
custom.coef.map |
The Users must supply a named list of this form:
|
custom.note |
With this argument, a replacement text for the
significance note below the table can be provided. If an empty
If the |
override.coef |
Set custom values for the coefficients. New coefficients
are provided as a list of numeric vectors. The list contains vectors of
coefficients for each model. There must be as many vectors of coefficients
as there are models. For example, if there are two models with three model
terms each, the argument could be specified as |
override.se |
Set custom values for the standard errors. New standard
errors are provided as a list of numeric vectors. The list contains vectors
of standard errors for each model. There must be as many vectors of
standard errors as there are models. For example, if there are two models
with three coefficients each, the argument could be specified as
|
override.pval |
Set custom values for the p-values. New p-values are
provided as a list of numeric vectors. The list contains vectors of
p-values for each model. There must be as many vectors of p-values as there
are models. For example, if there are two models with three coefficients
each, the argument could be specified as |
override.ci.low |
Set custom lower confidence interval bounds. This
works like the other override arguments, with one exception: if confidence
intervals are provided here and in the |
override.ci.up |
Set custom upper confidence interval bounds. This
works like the other override arguments, with one exception: if confidence
intervals are provided here and in the |
override.pvalues |
Set custom values for the p-values. New p-values are
provided as a list of numeric vectors. The list contains vectors of
p-values for each model. There must be as many vectors of p-values as there
are models. For example, if there are two models with three coefficients
each, the argument could be specified as |
omit.coef |
A character string which is used as a regular expression to
remove coefficient rows from the table. For example, |
reorder.coef |
Reorder the rows of the coefficient block of the
resulting table in a custom way. The argument takes a vector of the same
length as the number of coefficients. For example, if there are three
coefficients, |
ci.level |
If standard errors are converted to confidence intervals
(because a model does not natively support CIs), what confidence level
should be used for the outer confidence interval? By default, |
ci.force |
Should confidence intervals be used instead of the default
standard errors and p-values? Most models implemented in the texreg
package report standard errors and p-values by default while few models
report confidence intervals. However, the functions in the texreg
package can convert standard errors and into confidence intervals using
z-scores if desired. To enforce confidence intervals instead of standard
errors, the |
ci.force.level |
If the |
ci.test |
If confidence intervals are reported, the |
type |
The default option is |
theme |
The |
signif.light |
Color of outer confidence intervals for significant model terms. |
signif.medium |
Color of inner confidence intervals for significant model terms. |
signif.dark |
Color of point estimates and labels for significant model terms. |
insignif.light |
Color of outer confidence intervals for insignificant model terms. |
insignif.medium |
Color of inner confidence intervals for insignificant model terms. |
insignif.dark |
Color of point estimates and labels for insignificant model terms. |
... |
Custom options to be passed on to the |
The plotreg
function produces coefficient plots (i.e., forest plots
applied to point estimates and confidence intervals) and works much like the
screenreg
, texreg
, htmlreg
,
matrixreg
and wordreg
functions. It accepts a
single model or multiple statistical models as input and internally extracts
the relevant data from the models. If confidence intervals are not defined in
the extract method of a statistical model (see extract), the default
standard errors are converted to confidence intervals. Most of the arguments
work like in the screenreg
, texreg
, and
htmlreg
matrixreg
, and wordreg
functions. It is possible to display the plots in two ways: using the
type = "facet"
argument, one forest plot applied to point estimates
and confidence intervals will be visualized in case there is only one model.
If there is more than one model, each one will be plotted next to the other
as a separate facet; using the type = "forest"
argument, coefficients
from one or more models will be grouped together and displayed as a single
forest plot.
Coefficient plot as a ggplot2 gg
object if
file = FALSE
. NULL
otherwise.
Claudia Zucca, Philip Leifeld
texreg-package
extract
texreg
matrixreg
Other texreg:
htmlreg()
,
huxtablereg()
,
knitreg()
,
matrixreg()
,
screenreg()
,
texreg
,
wordreg()
## Not run:
# example from the 'lm' help file:
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)
lm.D9 <- lm(weight ~ group)
lm.D90 <- lm(weight ~ group - 1)
plotreg(lm.D9) # plot model output as a diagram
# customize theme and title and save as a PDF file.
plotreg(lm.D9,
theme = theme_dark(),
ggtitle = "my title",
file = "myplot.pdf")
unlink("myplot.pdf")
# group coefficients from multiple models
plotreg(list(lm.D9, lm.D90), type = "forest")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.