Model coefficients for fitted models with the model summary as a caption.
ggcoefstats(x, output = "plot", statistic = NULL, scales = NULL,
conf.method = "Wald", p.kr = TRUE, coefficient.type = "beta",
effsize = "eta", partial = TRUE, nboot = 500,
point.color = "blue", point.size = 3, point.shape = 16,
conf.int = TRUE, conf.level = 0.95, se.type = "nid", k = 2,
k.caption.summary = 0, exclude.intercept = TRUE,
exponentiate = FALSE, errorbar.color = "black",
errorbar.height = 0, errorbar.linetype = "solid",
errorbar.size = 0.5, vline = TRUE, vline.color = "black",
vline.linetype = "dashed", vline.size = 1, sort = "none",
xlab = "regression coefficient", ylab = "term", title = NULL,
subtitle = NULL, stats.labels = TRUE, caption.summary = TRUE,
stats.label.size = 3, stats.label.fontface = "bold",
stats.label.color = NULL, label.r = 0.15, label.size = 0.25,
label.box.padding = 1, label.label.padding = 0.25,
label.point.padding = 0.5, label.segment.color = "grey50",
label.segment.size = 0.5, label.segment.alpha = NULL,
label.min.segment.length = 0.5, label.force = 1,
label.max.iter = 2000, label.nudge.x = 0, label.nudge.y = 0,
label.xlim = c(NA, NA), label.ylim = c(NA, NA),
label.direction = "y", package = "RColorBrewer", palette = "Dark2",
direction = 1, ggtheme = ggplot2::theme_bw(),
ggstatsplot.layer = TRUE, ...)
A model object to be tidied with broom::tidy
, or a tidy data frame
containing results. If a data frame is to be plotted, it must contain
columns named term
(names of predictors), or estimate
(corresponding
estimates of coefficients or other quantities of interest). Other optional
columns are conf.low
and conf.high
(for confidence intervals);
p.value
.
Character describing the expected output from this function:
"plot"
(visualization of regression coefficients) or "tidy"
(tidy
dataframe of results from broom::tidy
) or "glance"
(object from
broom::glance
) or "augment"
(object from broom::augment
).
Which statistic is to be displayed (either "t"
or "f"
or
"z"
) in the label. This is especially important if the x
argument in
ggcoefstats
is a dataframe in which case the function wouldn't know what
kind of model it is dealing with.
scales on which to report the variables: for random effects, the choices are ‘"sdcor"’ (standard deviations and correlations: the default if scales
is NULL
) or ‘"vcov"’ (variances and covariances). NA
means no transformation, appropriate e.g. for fixed effects; inverse-link transformations (exponentiation or logistic) are not yet implemented, but may be in the future.
Character describing method for computing confidence
intervals (for more, see lme4::confint.merMod
). This argument is valid
only for the merMod
class model objects (lmer
, glmer
, nlmer
, etc.).
Logical, if TRUE
, the computation of p-values for lmer
is
based on conditional F-tests with Kenward-Roger approximation for the df.
For details, see ?sjstats::p_value
.
Relevant only for ordinal regression models (clm
and clmm
), this argument decides which parameters to display in the plot.
By default only "beta"
(a vector of regression parameters) parameters
will be show. Other options are "alpha"
(a vector of threshold
parameters) or "both"
.
Character describing the effect size to be displayed: "eta"
(default) or "omega"
. This argument is relevant
only for models objects of class aov
, anova
, and aovlist
.
Logical that decides if partial eta-squared or omega-squared
are returned (Default: TRUE
). If FALSE
, eta-squared or omega-squared
will be returned. Valid only for objects of class aov
, anova
, or
aovlist
.
Number of bootstrap samples for confidence intervals for partial
eta-squared and omega-squared (Default: 500
). This argument is relevant
only for models objects of class aov
, anova
, and aovlist
.
Character describing color for the point (Default:
"blue"
).
Numeric specifying size for the point (Default: 3
).
Numeric specifying shape to draw the points (Default: 16
(a dot)).
Logical. Decides whether to display confidence intervals as
error bars (Default: TRUE
).
Numeric deciding level of confidence intervals (Default:
0.95
).
Character specifying the method used to compute standard
standard errors for quantile regression (Default: "nid"
). To see all
available methods, see quantreg::summary.rq()
.
Number of decimal places expected for results displayed in labels
(Default : k = 2
).
Number of decimal places expected for results
displayed in captions (Default : k.caption.summary = 0
).
Logical that decides whether the intercept should be
excluded from the plot (Default: TRUE
).
If TRUE
, the x
-axis will be logarithmic (Default:
FALSE
).
Character deciding color of the error bars (Default:
"black"
).
Numeric specifying the height of the error bars
(Default: 0
).
Line type of the error bars (Default: "solid"
).
Numeric specifying the size of the error bars (Default:
0.5
).
Decides whether to display a vertical line (Default: "TRUE"
).
Character specifying color of the vertical line (Default:
"black"
).
Character specifying line type of the vertical line
(Default: "dashed"
).
Numeric specifying the size of the vertical line (Default:
1
).
If "none"
(default) do not sort, "ascending"
sort by
increasing coefficient value, or "descending"
sort by decreasing
coefficient value.
Label for x
axis variable (Default: "estimate"
).
Label for y
axis variable (Default: "term"
).
The text for the plot title.
The text for the plot subtitle.
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
).
Logical. Decides whether the model summary should be
displayed as a cation to the plot (Default: TRUE
). Color of the line
segment. Defaults to the same color as the text.
Aesthetics for
the labels. Defaults: 3
, "bold"
,NULL
, resp. If stats.label.color
is
NULL
, colors will be chosen from the specified package
(Default:
"RColorBrewer"
) and palette
(Default: "Dark2"
).
Radius of rounded corners, as unit or number. Defaults to
0.15
. (Default unit is lines).
Size of label border, in mm. Defaults to 0.25
.
Amount of padding around bounding box, as number.
Defaults to 1
. (Default unit is lines).
Amount of padding around label, as number.
Defaults to 0.25
. (Default unit is lines).
Amount of padding around labeled point, as
number. Defaults to 0
. (Default unit is lines).
Color of the line segment (Default: "grey50"
).
Width of line segment connecting the data point to
the text label, in mm. Defaults to 0.5
.
Transparency of the line segment. Defaults to the same transparency as the text.
Skip drawing segments shorter than this.
Defaults to 0.5
. (Default unit is lines).
Force of repulsion between overlapping text labels.
Defaults to 1
.
Maximum number of iterations to try to resolve
overlaps. Defaults to 2000
.
Horizontal and vertical adjustments to
nudge the starting position of each text label. Defaults to 0
.
Limits for the x and y axes. Text labels will be
constrained to these limits. By default, text labels are constrained to the
entire plot area. Defaults to c(NA, NA)
.
Character ("both"
, "x"
, or "y"
) -- direction in
which to adjust position of labels (Default: "y"
).
Name of package from which the palette is desired as string or symbol.
Name of palette as string or symbol.
Either 1
or -1
. If -1
the palette will be reversed.
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_economist()
,
hrbrthemes::theme_ipsum_ps()
, ggthemes::theme_fivethirtyeight()
, etc.).
Logical that decides whether theme_ggstatsplot
theme elements are to be displayed along with the selected ggtheme
(Default: TRUE
).
Additional arguments to tidying method.
Plot with the regression coefficients' point estimates as dots with confidence interval whiskers.
https://cran.r-project.org/package=ggstatsplot/vignettes/ggcoefstats.html
# NOT RUN {
# for reproducibility
set.seed(123)
# with model object
ggcoefstats(x = lm(formula = mpg ~ cyl * am, data = mtcars))
# with custom dataframe
# creating a dataframe
df <- tibble::tribble(
~term, ~statistic, ~estimate, ~conf.low, ~conf.high, ~p.value,
"level1", 1.33, 0.542, -0.280, 1.36, 0.191,
"level2", 0.158, 0.0665, -0.778, 0.911, 0.875
)
# plotting the dataframe
ggstatsplot::ggcoefstats(x = df, statistic = "t")
# }
Run the code above in your browser using DataLab