statsExpressions (version 0.3.1)

corr_objects: Create all needed objects for correlation matrix.

Description

This function is mostly useful in the context of ggstatsplot::ggcorrmat. It returns the correlation matrix, p-value matrix, and a correlation object from psych/WRS2 package that contains all the details about the test.

Usage

corr_objects(
  data,
  ci = FALSE,
  corr.method = "pearson",
  p.adjust.method = "none",
  beta = 0.1,
  k = 2,
  ...
)

Arguments

data

Dataframe from which variables specified are preferentially to be taken. Only numeric variables should be present.

ci

By default, confidence intervals are found. However, this leads to a noticable slowdown of speed, particularly for large problems. So, for just the rs, ts and ps, set ci=FALSE

corr.method

A character string indicating which correlation coefficient is to be computed ("pearson" (default) or "kendall" or "spearman"). "robust" can also be entered but only if output argument is set to either "correlations" or "p-values". The robust correlation used is percentage bend correlation (see ?WRS2::pball). Abbreviations will also work: "p" (for parametric/Pearson's r), "np" (nonparametric/Spearman's rho), "r" (robust).

p.adjust.method

What adjustment for multiple tests should be used? ("holm", "hochberg", "hommel", "bonferroni", "BH", "BY", "fdr", "none"). See stats::p.adjust for details about why to use "holm" rather than "bonferroni"). Default is "none". If adjusted p-values are displayed in the visualization of correlation matrix, the adjusted p-values will be used for the upper triangle, while unadjusted p-values will be used for the lower triangle of the matrix.

beta

A numeric bending constant for percentage bend robust correlation coefficient (Default: 0.1).

k

Decides the number of decimal digits to be displayed (Default: 2).

...

Currently ignored.

Value

A list with all needed objects for displaying correlation tests in a correlation matrix visualization.

Examples

Run this code
# NOT RUN {
# only numeric variables
df <- purrr::keep(WRS2::diet, purrr::is_bare_numeric)

# using function
corr_objects(df)
# }

Run the code above in your browser using DataLab