Plot with the regression coefficients' point estimates as dots with confidence interval whiskers and other statistical details included as labels.
ggcoefstats(
x,
output = "plot",
statistic = NULL,
conf.int = TRUE,
conf.level = 0.95,
k = 2L,
exclude.intercept = FALSE,
effsize = "eta",
meta.analytic.effect = FALSE,
meta.type = "parametric",
bf.message = TRUE,
sort = "none",
xlab = "regression coefficient",
ylab = "term",
title = NULL,
subtitle = NULL,
caption = NULL,
only.significant = FALSE,
point.args = list(size = 3, color = "blue"),
errorbar.args = list(height = 0),
vline = TRUE,
vline.args = list(size = 1, linetype = "dashed"),
stats.labels = TRUE,
stats.label.color = NULL,
stats.label.args = list(size = 3, direction = "y"),
package = "RColorBrewer",
palette = "Dark2",
ggtheme = ggplot2::theme_bw(),
ggstatsplot.layer = TRUE,
...
)
A model object to be tidied, or a tidy data frame containing results
from a regression model. Function internally uses
parameters::model_parameters
to get a tidy dataframe. If
a data frame is used, it must contain columns named term
(names of
predictors) and estimate
(corresponding estimates of coefficients or
other quantities of interest).
Character describing the expected output from this function:
"plot"
(visualization of regression coefficients) or "tidy"
(tidy
dataframe of results parameters::model_parameters
) or "glance"
(object
from performance::model_performance
).
Which statistic is to be displayed (either "t"
or "f"
or
"z"
or "chi"
) in the label. This is relevant if the x
argument is a
dataframe.
Logical. Decides whether to display confidence intervals as
error bars (Default: TRUE
).
Numeric deciding level of confidence or credible intervals
(Default: 0.95
).
Number of digits after decimal point (should be an integer)
(Default: k = 2L
).
Logical that decides whether the intercept should be
excluded from the plot (Default: FALSE
).
Character describing the effect size to be displayed: "eta"
(default) or "omega"
. This argument is relevant only for models objects
of class aov
, anova
, aovlist
, "Gam"
, and "manova"
.
Logical that decides whether subtitle for
meta-analysis via linear (mixed-effects) models (default: FALSE
). If
TRUE
, input to argument subtitle
will be ignored. This will be mostly
relevant if a data frame with estimates and their standard errors is
entered.
Type of statistics used to carry out random-effects
meta-analysis. If "parametric"
(default), metafor::rma
function will be
used. If "robust"
, metaplus::metaplus
function will be used. If
"bayes"
, metaBMA::meta_random
function will be used.
Logical that decides whether results from running a
Bayesian meta-analysis assuming that the effect size d varies across
studies with standard deviation t (i.e., a random-effects analysis)
should be displayed in caption. Defaults to TRUE
.
If "none"
(default) do not sort, "ascending"
sort by
increasing coefficient value, or "descending"
sort by decreasing
coefficient value.
Labels for x
- and y
- axis variables, respectively
(Defaults: "regression coefficient"
and "term"
).
The text for the plot title.
The text for the plot subtitle. The input to this argument
will be ignored if meta.analytic.effect
is set to TRUE
.
The text for the plot caption.
If TRUE
, only stats labels for significant effects
is shown (Default: FALSE
). This can be helpful when a large number of
regression coefficients are to be displayed in a single plot. Relevant only
when the output
is a plot.
Additional arguments that will be passed to
ggplot2::geom_point
geom. Please see documentation for that function to
know more about these arguments.
Additional arguments that will be passed to
ggplot2::geom_errorbarh
geom. Please see documentation for that function
to know more about these arguments.
Decides whether to display a vertical line (Default: "TRUE"
).
Additional arguments that will be passed to
ggplot2::geom_vline
geom. Please see documentation for that function to
know more about these arguments.
Logical. Decides whether the statistic and p-values for
each coefficient are to be attached to each dot as a text label using
ggrepel
(Default: TRUE
).
Color for the labels. If set to NULL
, colors will
be chosen from the specified package
(Default: "RColorBrewer"
) and
palette
(Default: "Dark2"
).
Additional arguments that will be passed to
ggrepel::geom_label_repel
geom. Please see documentation for that
function to know more about these arguments.
Name of the package from which the given palette is to
be extracted. The available palettes and packages can be checked by running
View(paletteer::palettes_d_names)
.
Name of the package from which the given palette is to
be extracted. The available palettes and packages can be checked by running
View(paletteer::palettes_d_names)
.
A function, ggplot2
theme name. Default value is
ggplot2::theme_bw()
. Any of the ggplot2
themes, or themes from
extension packages are allowed (e.g., ggthemes::theme_fivethirtyeight()
,
hrbrthemes::theme_ipsum_ps()
, etc.).
Logical that decides whether theme_ggstatsplot
theme elements are to be displayed along with the selected ggtheme
(Default: TRUE
). theme_ggstatsplot
is an opinionated theme layer that
override some aspects of the selected ggtheme
.
Additional arguments to tidying method. For more, see
parameters::model_parameters
.
https://indrajeetpatil.github.io/ggstatsplot/articles/web_only/ggcoefstats.html
# NOT RUN {
# for reproducibility
set.seed(123)
library(ggstatsplot)
# model object
mod <- lm(formula = mpg ~ cyl * am, data = mtcars)
# to get a plot
ggcoefstats(x = mod, output = "plot")
# to get a tidy dataframe
ggcoefstats(x = mod, output = "tidy")
# to get a glance summary
ggcoefstats(x = mod, output = "glance")
# }
Run the code above in your browser using DataLab