Skip to content

Commit

Permalink
Merge branch 'main' into openxlsx2
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy authored Aug 7, 2024
2 parents 1006061 + 76439be commit 6889a8e
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 119 deletions.
26 changes: 13 additions & 13 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: correlation
Title: Methods for Correlation Analysis
Version: 0.8.5
Authors@R:
Version: 0.8.5.1
Authors@R:
c(person(given = "Dominique",
family = "Makowski",
role = c("aut", "inv"),
Expand All @@ -28,19 +28,19 @@ Authors@R:
role = "aut",
email = "[email protected]",
comment = c(ORCID = "0000-0002-4287-4801", Twitter = "@mattansb")),
person(given = "Rémi",
person(given = "Rémi",
family = "Thériault",
role = c("aut"),
role = c("aut"),
email = "[email protected]",
comment = c(ORCID = "0000-0003-4315-6788", Twitter = "@rempsyc")),
person(given = "Mark",
family = "White",
person(given = "Mark",
family = "White",
email = "[email protected]",
role = "rev"),
person(given = "Maximilian M.",
family = "Rabe",
email = "[email protected]",
role = "rev",
person(given = "Maximilian M.",
family = "Rabe",
email = "[email protected]",
role = "rev",
comment = c(ORCID = "0000-0002-2556-5644")))
Maintainer: Brenton M. Wiernik <[email protected]>
Description: Lightweight package for computing different kinds
Expand All @@ -56,7 +56,7 @@ Depends:
Imports:
bayestestR (>= 0.13.2),
datasets,
datawizard (>= 0.11.0),
datawizard (>= 0.10.0),
insight (>= 0.20.0),
parameters (>= 0.21.7),
stats
Expand Down Expand Up @@ -84,11 +84,11 @@ Suggests:
wdm,
WRS2,
openxlsx2 (>= 1.0)
VignetteBuilder:
VignetteBuilder:
knitr
Encoding: UTF-8
Language: en-US
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 3
Config/Needs/website:
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# correlation 0.8.6

- Fix CRAN check issues.

# correlation 0.8.5

- New `cormatrix_to_excel()` function for exporting correlation matrices to Excel with color formatting.
Expand Down Expand Up @@ -206,4 +210,3 @@
- Fixed issue in `correlation()` for correlation coefficients with less than
four complete pairs of observations (in such cases, `cor_test()` now returns
`NA` for the confidence intervals).

58 changes: 28 additions & 30 deletions R/cor_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@
#' @param ci Confidence/Credible Interval level. If `"default"`, then it is
#' set to `0.95` (`95%` CI).
#' @param method 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.
#' 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.
#' @param bayesian If `TRUE`, will run the correlations under a Bayesian
#' framework.
#' @param partial_bayesian If partial correlations under a Bayesian framework
Expand All @@ -28,30 +27,29 @@
#' pseudo-Bayesian partial correlations (i.e., Bayesian correlation based on
#' frequentist partialization).
#' @param include_factors If `TRUE`, the factors are kept and eventually
#' converted to numeric or used as random effects (depending of
#' `multilevel`). If `FALSE`, factors are removed upfront.
#' @param partial Can be `TRUE` or `"semi"` for partial and
#' semi-partial correlations, respectively.
#' converted to numeric or used as random effects (depending of `multilevel`).
#' If `FALSE`, factors are removed upfront.
#' @param partial Can be `TRUE` or `"semi"` for partial and semi-partial
#' correlations, respectively.
#' @inheritParams datawizard::adjust
#' @param bayesian_prior For the prior argument, several named values are
#' recognized: `"medium.narrow"`, `"medium"`, `"wide"`, and
#' `"ultrawide"`. These correspond to scale values of `1/sqrt(27)`,
#' `1/3`, `1/sqrt(3)` and `1`, respectively. See the
#' `BayesFactor::correlationBF` function.
#' recognized: `"medium.narrow"`, `"medium"`, `"wide"`, and `"ultrawide"`.
#' These correspond to scale values of `1/sqrt(27)`, `1/3`, `1/sqrt(3)` and
#' `1`, respectively. See the `BayesFactor::correlationBF` function.
#' @param bayesian_ci_method,bayesian_test See arguments in
#' [`model_parameters()`][parameters] for `BayesFactor` tests.
#' [`parameters::model_parameters()`] for `BayesFactor` tests.
#' @param ranktransform If `TRUE`, will rank-transform the variables prior to
#' estimating the correlation, which is one way of making the analysis more
#' resistant to extreme values (outliers). Note that, for instance, a Pearson's
#' correlation on rank-transformed data is equivalent to a Spearman's rank
#' correlation. Thus, using `robust=TRUE` and `method="spearman"` is
#' redundant. Nonetheless, it is an easy option to increase the robustness of the
#' correlation as well as flexible way to obtain Bayesian or multilevel
#' Spearman-like rank correlations.
#' resistant to extreme values (outliers). Note that, for instance, a
#' Pearson's correlation on rank-transformed data is equivalent to a
#' Spearman's rank correlation. Thus, using `robust=TRUE` and
#' `method="spearman"` is redundant. Nonetheless, it is an easy option to
#' increase the robustness of the correlation as well as flexible way to
#' obtain Bayesian or multilevel Spearman-like rank correlations.
#' @param winsorize Another way of making the correlation more "robust" (i.e.,
#' limiting the impact of extreme values). Can be either `FALSE` or a
#' number between 0 and 1 (e.g., `0.2`) that corresponds to the desired
#' threshold. See the [`winsorize()`][winsorize] function for more details.
#' limiting the impact of extreme values). Can be either `FALSE` or a number
#' between 0 and 1 (e.g., `0.2`) that corresponds to the desired threshold.
#' See the [`datawizard::winsorize()`] function for more details.
#' @param verbose Toggle warnings.
#' @param ... Additional arguments (e.g., `alternative`) to be passed to
#' other methods. See `stats::cor.test` for further details.
Expand Down
12 changes: 10 additions & 2 deletions R/cor_test_bayes.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@

if (x == y) {
# Avoid error in the case of perfect correlation
rez <- BayesFactor::correlationBF(stats::rnorm(1000), stats::rnorm(1000), rscale = bayesian_prior)
rez <- suppressWarnings(BayesFactor::correlationBF(
stats::rnorm(1000),
stats::rnorm(1000),
rscale = bayesian_prior
))
params <- parameters::model_parameters(
rez,
dispersion = FALSE,
Expand All @@ -79,7 +83,11 @@
if ("ROPE_Percentage" %in% names(params)) params$ROPE_Percentage <- 0
if ("BF" %in% names(params)) params$BF <- Inf
} else {
rez <- BayesFactor::correlationBF(var_x, var_y, rscale = bayesian_prior)
rez <- suppressWarnings(BayesFactor::correlationBF(
var_x,
var_y,
rscale = bayesian_prior
))
params <- parameters::model_parameters(
rez,
dispersion = FALSE,
Expand Down
58 changes: 28 additions & 30 deletions man/cor_test.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 11 additions & 12 deletions man/cor_to_p.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6889a8e

Please sign in to comment.