ggstatsplot (version 0.0.4)

ggcoefstats: Model coefficients for fitted models with the model summary as a caption.

Description

Model coefficients for fitted models with the model summary as a caption.

Usage

ggcoefstats(x, output = "plot", effects = "fixed", scales = NULL,
  ran.prefix = NULL, conf.method = "Wald", coefficient.type = "beta",
  effsize = "eta", nboot = 1000, point.color = "blue", point.size = 3,
  point.shape = 16, conf.int = TRUE, conf.level = 0.95, k = 3,
  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 = "black",
  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", ggtheme = ggplot2::theme_bw(), ...)

Arguments

x

A model object to be tidied with broom::tidy.

output

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).

effects

In case the object is of class merMod (lmerMod, glmerMod, nlmerMod), these arguments determine which effects are to be displayed. By default, only the "fixed" effects will be shown. Other option is "ran_pars".

scales

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.

ran.prefix

A length-2 character vector specifying the strings to use as prefixes for self- (variance/standard deviation) and cross- (covariance /correlation) random effects terms.

conf.method

method for computing confidence intervals (see lme4::confint.merMod)

coefficient.type

For ordinal regression models, 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".

effsize

Character describing the effect size to be displayed: "eta" (default) or "omega".

nboot

Number of bootstrap samples for confidence intervals for partial eta-squared and omega-squared (Default: 1000).

point.color

Character describing color for the point (Default: "blue").

point.size

Numeric specifying size for the point (Default: 3).

point.shape

Numeric specifying shape to draw the points (Default: 16 (a dot)).

conf.int

Logical. Decides whether to display confidence intervals as error bars (Default: TRUE).

conf.level

Numeric deciding level of confidence intervals (Default: 0.95).

k

Number of decimal places expected for results displayed in labels.

k.caption.summary

Number of decimal places expected for results displayed in captions.

exclude.intercept

Logical that decides whether the intercept should be excluded from the plot (Default: TRUE).

exponentiate

If TRUE, the x-axis will be logarithmic (Default: FALSE).

errorbar.color

Character deciding color of the error bars (Default: "black").

errorbar.height

Numeric specifying the height of the error bars (Default: 0).

errorbar.linetype

Line type of the error bars (Default: "solid").

errorbar.size

Numeric specifying the size of the error bars (Default: 0.5).

vline

Decides whether to display a vertical line (Default: "TRUE").

vline.color

Character specifying color of the vertical line (Default: "black").

vline.linetype

Character specifying line type of the vertical line (Default: "dashed").

vline.size

Numeric specifying the size of the vertical line (Default: 1).

sort

"none" (default) do not sort, "ascending" sort by increasing coefficient value, or "descending" sort by decreasing coefficient value.

xlab

Label for x axis variable (Default: "estimate").

ylab

Label for y axis variable (Default: "term").

title

The text for the plot title.

subtitle

The text for the plot subtitle.

stats.labels

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).

caption.summary

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.

stats.label.size, stats.label.fontface, stats.label.color

Aesthetics for the labels. Defaults: 3, "bold","black", resp.

label.r,

Radius of rounded corners, as unit or number. Defaults to 0.15. (Default unit is lines).

label.size

Size of label border, in mm. Defaults to 0.25.

label.box.padding

Amount of padding around bounding box, as number. Defaults to 1. (Default unit is lines).

label.label.padding

Amount of padding around label, as number. Defaults to 0.25. (Default unit is lines).

label.point.padding

Amount of padding around labeled point, as number. Defaults to 0. (Default unit is lines).

label.segment.color

Color of the line segment (Default: "grey50").

label.segment.size

Width of line segment connecting the data point to the text label, in mm. Defaults to 0.5.

label.segment.alpha

Transparency of the line segment. Defaults to the same transparency as the text.

label.min.segment.length

Skip drawing segments shorter than this. Defaults to 0.5. (Default unit is lines).

label.force

Force of repulsion between overlapping text labels. Defaults to 1.

label.max.iter

Maximum number of iterations to try to resolve overlaps. Defaults to 2000.

label.nudge.x, label.nudge.y

Horizontal and vertical adjustments to nudge the starting position of each text label. Defaults to 0.

label.xlim, label.ylim

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).

label.direction

Character ("both", "x", or "y") -- direction in which to adjust position of labels (Default: "y").

ggtheme

A function, ggplot2 theme name. Default value is ggplot2::theme_bw(). Allowed values are the official ggplot2 themes, including theme_bw(), theme_minimal(), theme_classic(), theme_void(), etc.

Extra arguments to pass to tidy.

Value

Plot with the regression coefficients' point estimates as dots with confidence interval whiskers.

Examples

Run this code
# NOT RUN {
set.seed(123)
ggcoefstats(x = lm(formula = mpg ~ cyl * am, data = mtcars))

# }

Run the code above in your browser using DataCamp Workspace