ggscatterstats {ggstatsplot} | R Documentation |
Scatterplots from {ggplot2}
combined with marginal densigram (density +
histogram) plots with statistical details.
ggscatterstats( data, x, y, type = "parametric", conf.level = 0.95, bf.prior = 0.707, bf.message = TRUE, tr = 0.2, k = 2L, results.subtitle = TRUE, label.var = NULL, label.expression = NULL, marginal = TRUE, point.args = list(size = 3, alpha = 0.4, stroke = 0), point.width.jitter = 0, point.height.jitter = 0, point.label.args = list(size = 3, max.overlaps = 1e+06), smooth.line.args = list(linewidth = 1.5, color = "blue", method = "lm", formula = y ~ x), xsidehistogram.args = list(fill = "#009E73", color = "black", na.rm = TRUE), ysidehistogram.args = list(fill = "#D55E00", color = "black", na.rm = TRUE), xlab = NULL, ylab = NULL, title = NULL, subtitle = NULL, caption = NULL, ggtheme = ggstatsplot::theme_ggstatsplot(), ggplot.component = NULL, ... )
data |
A data frame (or a tibble) from which variables specified are to
be taken. Other data types (e.g., matrix,table, array, etc.) will not
be accepted. Additionally, grouped data frames from |
x |
The column in |
y |
The column in |
type |
A character specifying the type of statistical approach:
You can specify just the initial letter. |
conf.level |
Scalar between |
bf.prior |
A number between |
bf.message |
Logical that decides whether to display Bayes Factor in
favor of the null hypothesis. This argument is relevant only for
parametric test (Default: |
tr |
Trim level for the mean when carrying out |
k |
Number of digits after decimal point (should be an integer)
(Default: |
results.subtitle |
Decides whether the results of statistical tests are
to be displayed as a subtitle (Default: |
label.var |
Variable to use for points labels entered as a symbol (e.g.
|
label.expression |
An expression evaluating to a logical vector that
determines the subset of data points to label (e.g. |
marginal |
Decides whether marginal distributions will be plotted on
axes using |
point.args |
A list of additional aesthetic arguments to be passed
to |
point.width.jitter, point.height.jitter |
Degree of jitter in |
point.label.args |
A list of additional aesthetic arguments to be passed
to |
smooth.line.args |
A list of additional aesthetic arguments to be passed
to |
xsidehistogram.args, ysidehistogram.args |
A list of arguments passed to
respective |
xlab |
Label for |
ylab |
Labels for |
title |
The text for the plot title. |
subtitle |
The text for the plot subtitle. Will work only if
|
caption |
The text for the plot caption. This argument is relevant only
if |
ggtheme |
A |
ggplot.component |
A |
... |
Currently ignored. |
For details, see: https://indrajeetpatil.github.io/ggstatsplot/articles/web_only/ggscatterstats.html
graphical element | geom used | argument for further modification |
histogram bin | ggplot2::stat_bin() | bin.args |
centrality measure line | ggplot2::geom_vline() | centrality.line.args |
normality curve | ggplot2::stat_function() | normal.curve.args |
The table below provides summary about:
statistical test carried out for inferential statistics
type of effect size estimate and a measure of uncertainty for this estimate
functions used internally to compute these details
Hypothesis testing and Effect size estimation
Type | Test | CI available? | Function used |
Parametric | Pearson's correlation coefficient | Yes | correlation::correlation() |
Non-parametric | Spearman's rank correlation coefficient | Yes | correlation::correlation() |
Robust | Winsorized Pearson's correlation coefficient | Yes | correlation::correlation() |
Bayesian | Bayesian Pearson's correlation coefficient | Yes | correlation::correlation() |
The plot uses ggrepel::geom_label_repel()
to attempt to keep labels
from over-lapping to the largest degree possible. As a consequence plot
times will slow down massively (and the plot file will grow in size) if you
have a lot of labels that overlap.
grouped_ggscatterstats
, ggcorrmat
,
grouped_ggcorrmat
set.seed(123) library(ggside) # for plotting marginals # creating a plot p <- ggscatterstats( iris, x = Sepal.Width, y = Petal.Length, label.var = Species, label.expression = Sepal.Length > 7.6 ) + ggplot2::geom_rug(sides = "b") # looking at the plot p # extracting details from statistical tests extract_stats(p)