plot_rdiff
helps visualize comparisons of Pearson's r
estimates between conditions. It plots the Pearson's r value for each
level of a grouping variable and emphasizes a 1-df comparison among
conditions, plotting the estimated difference and its confidence interval
with a difference axis. You can pass esci-estimate objects generated
by estimate_rdiff_two()
. This function returns a ggplot2 object.
Arguments
- estimate
An esci-estimate object generated by an estimate_pdiff_ function
- error_layout
Optional; one of 'halfeye', 'eye', 'gradient' or 'none' to determine how expected error distribution will be displayed for each estimated parameter. Defaults to 'halfeye'. Currently does not apply if 'median' is selected as effect size, in which case a simple error bar will be used
- error_scale
Optional numeric determining width of the expected error distribution. Defaults to 0.3
- error_normalize
Optional; one of 'groups', 'all', or 'panels' to determine how width of the expected error distributions will be normalized. Defaults to 'groups'. See documentation in ggdist
- difference_axis_breaks
Optional numeric > 1 of suggested number of breaks for the difference axis. Defaults to 5
- simple_contrast_labels
Optional logical to determine if contrasts are given simple labels ('Reference', 'Comparison', 'Difference') or more descriptive labels based on the contrast specified.
- ylim
Optional 2-item vector specifying y-axis limits. Defaults to c(NA NA); Use NA to specify auto-limit.
- ybreaks
Optional numeric > 2 for suggested number of y-axis breaks; defaults to 5
- rope
Optional 2-item vector with item 2 >= item 1. Use to specify a range of values to use to visualize a hypothesis test. If both values are the same, a point-null hypothesis test will be visualized. If item2 > item1 an interval-null hypothesis test will be visualized. Defaults to c(NA, NA), which is to not visualize a hypothesis test
- ggtheme
Optional ggplot2 theme object to specify the visual style of the plot. Defaults to
ggplot2::theme_classic()
Details
This function was developed primarily for student use within jamovi when learning along with the text book Introduction to the New Statistics, 2nd edition (Cumming & Calin-Jageman, 2024).
Expect breaking changes as this function is improved for general use. Work still do be done includes:
Revise to avoid deprecated ggplot features
Revise for consistent ability to control aesthetics and consistent layer names
Examples
# From raw data
data("data_campus_involvement")
estimate_from_raw <- esci::estimate_rdiff_two(
esci::data_campus_involvement,
GPA,
SWB,
Gender
)
# To visualize the difference in r
myplot_from_raw <- esci::plot_rdiff(estimate_from_raw)
#> Warning: Using size for a discrete variable is not advised.
#> Warning: Using alpha for a discrete variable is not advised.
#> Warning: Using size for a discrete variable is not advised.
#> Warning: Using alpha for a discrete variable is not advised.
# To visualize the data (scatterplot) by group
myplot_scatter <- esci::plot_scatter(estimate_from_raw)
# To evaluate a hypothesis (by default: point null of exaclty 0):
res_htest_from_raw <- esci::test_rdiff(
estimate_from_raw
)
# From summary data
estimate <- esci::estimate_rdiff_two(
comparison_r = .53,
comparison_n = 45,
reference_r = .41,
reference_n = 59,
grouping_variable_levels = c("Females", "Males"),
x_variable_name = "Satisfaction with life",
y_variable_name = "Body satisfaction",
grouping_variable_name = "Gender",
conf_level = .95
)
myplot_from_summary <- esci::plot_rdiff(estimate)
#> Warning: Using size for a discrete variable is not advised.
#> Warning: Using alpha for a discrete variable is not advised.
#> Warning: Using size for a discrete variable is not advised.
#> Warning: Using alpha for a discrete variable is not advised.
# To evaluate a hypothesis (interval null from -0.1 to 0.1):
res_htest_from_summary <- esci::test_rdiff(
estimate,
rope = c(-0.1, 0.1)
)