Get statistics, p-values and confidence intervals (CI) from correlation coefficients.
cor_to_ci(cor, n, ci = 0.95, method = "pearson", correction = "fieller", ...)cor_to_p(cor, n, method = "pearson")
A list containing a p-value and the statistic or the CI bounds.
A correlation matrix or coefficient.
The sample size (number of observations).
Confidence/Credible Interval level. If "default"
, then it is
set to 0.95
(95%
CI).
A character string indicating which correlation coefficient is
to be used for the test. One of "pearson"
(default),
"kendall"
, "spearman"
(but see also the robust
argument), "biserial"
,
"polychoric"
, "tetrachoric"
, "biweight"
,
"distance"
, "percentage"
(for percentage bend correlation),
"blomqvist"
(for Blomqvist's coefficient), "hoeffding"
(for
Hoeffding's D), "gamma"
, "gaussian"
(for Gaussian Rank
correlation) or "shepherd"
(for Shepherd's Pi correlation). Setting
"auto"
will attempt at selecting the most relevant method
(polychoric when ordinal factors involved, tetrachoric when dichotomous
factors involved, point-biserial if one dichotomous and one continuous and
pearson otherwise). See below the details section for a description of
these indices.
Only used if method is 'spearman' or 'kendall'. Can be 'fieller' (default; Fieller et al., 1957), 'bw' (only for Spearman) or 'none'. Bonett and Wright (2000) claim their correction ('bw') performs better, though the Bishara and Hittner (2017) paper favours the Fieller correction. Both are generally very similar.
Additional arguments (e.g., alternative
) to be passed to
other methods. See stats::cor.test
for further details.
Bishara, A. J., & Hittner, J. B. (2017). Confidence intervals for correlations when data are not normal. Behavior research methods, 49(1), 294-309.
cor.test(iris$Sepal.Length, iris$Sepal.Width)
cor_to_p(-0.1175698, n = 150)
cor_to_p(cor(iris[1:4]), n = 150)
cor_to_ci(-0.1175698, n = 150)
cor_to_ci(cor(iris[1:4]), n = 150)
cor.test(iris$Sepal.Length, iris$Sepal.Width, method = "spearman")
cor_to_p(-0.1667777, n = 150, method = "spearman")
cor_to_ci(-0.1667777, ci = 0.95, n = 150)
cor.test(iris$Sepal.Length, iris$Sepal.Width, method = "kendall")
cor_to_p(-0.07699679, n = 150, method = "kendall")
Run the code above in your browser using DataLab