corr_neat {neatStats} | R Documentation |
Correlation Statistics
Description
Pearson correlation
results
including confidence interval (CI) and correlation
Bayes factor
(BF). For
non-parametric version, Spearman's rank
correlation
results along with corresponding rank-based BFs (as per van
Doorn et al., 2020).
Usage
corr_neat(
var1,
var2,
nonparametric = FALSE,
ci = 0.95,
bf_added = FALSE,
direction = NULL,
round_r = 3,
for_table = FALSE,
sb_correction = FALSE,
hush = FALSE
)
Arguments
var1 |
Numeric vector; numbers of the first variable. |
var2 |
Numeric vector; numbers of the second variable. |
nonparametric |
Logical ( |
ci |
Numeric; confidence level for the returned CI, as implemented in
|
bf_added |
Logical. If |
direction |
|
round_r |
Number |
for_table |
Logical. If |
sb_correction |
Logical. If |
hush |
Logical. If |
Details
The Bayes factor (BF) is calculated with the default r-scale of
1/3
for parametric test, and with the default r-scale of 1
for
nonparametric test. BF supporting null hypothesis is denoted as BF01, while
that supporting alternative hypothesis is denoted as BF10. When the BF is
smaller than 1 (i.e., supports null hypothesis), the reciprocal is
calculated (hence, BF10 = BF, but BF01 = 1/BF). When the BF is greater than
or equal to 10000, scientific (exponential) form is reported for
readability. (The original full BF number is available in the returned named
vector as bf
.)#'
Value
Prints correlation statistics (including CI and BF) in APA style.
Furthermore, when assigned, returns a named vector with the following
elements: r
(Pearson correlation), p
(p value), bf
(Bayes factor).
Note
The correlation and CI is calculated via
stats::cor.test
.
The parametric Bayes factor is calculated via
BayesFactor::correlationBF
. The
nonparametric (rank-based) Bayes factor is a contribution by Johnny van Doorn;
the original source code is available via https://osf.io/gny35/.
References
Brown, W. (1910). Some experimental results in the correlation of mental abilities. British Journal of Psychology, 1904-1920, 3(3), 296-322. doi:10.1111/j.2044-8295.1910.tb00207.x
Eisinga, R., Grotenhuis, M. te, & Pelzer, B. (2013). The reliability of a two-item scale: Pearson, Cronbach, or Spearman-Brown? International Journal of Public Health, 58(4), 637-642. doi:10.1007/s00038-012-0416-3
Spearman, C. (1910). Correlation calculated from faulty data. British Journal of Psychology, 1904-1920, 3(3), 271-295. doi:10.1111/j.2044-8295.1910.tb00206.x
van Doorn, J., Ly, A., Marsman, M., & Wagenmakers, E.-J. (2020). Bayesian rank-based hypothesis testing for the rank sum test, the signed rank test, and Spearman’s rho. Journal of Applied Statistics, 1–23. doi:10.1080/02664763.2019.1709053
See Also
Examples
# assign two variables
v1 = c(11, 15, 19, 43, 53, -4, 34, 8, 33, -1, 54 )
v2 = c(4, -2, 23, 13, 32, 16, 3, 29, 37, -4, 65 )
corr_neat(v1, v2) # prints statistics
# one-sided, and omitting the "95% CI" part
corr_neat(v1, v2, direction = 'pos', for_table = TRUE)
# print statistics and assign main results
results = corr_neat(v1, v2, direction = 'pos')
results['p'] # get precise p value