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.
corr_objects(
data,
ci = FALSE,
corr.method = "pearson",
p.adjust.method = "none",
beta = 0.1,
k = 2,
...
)
Dataframe from which variables specified are preferentially to be taken. Only numeric variables should be present.
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
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).
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.
A numeric bending constant for percentage bend robust correlation
coefficient (Default: 0.1
).
Decides the number of decimal digits to be displayed
(Default: 2
).
Currently ignored.
A list with all needed objects for displaying correlation tests in a correlation matrix visualization.
# 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