Skip to content

Commit a71043f

Browse files
cor_smooth tol to match psych's default
otherwise it doesn't smooth properly it seems
1 parent 1256a65 commit a71043f

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

R/cor_smooth.R

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#' @param x A correlation matrix.
77
#' @param method Smoothing method. Can be `psych` (will use `psych::cor.smooth()`), `hj` (Jorjani et al., 2003) or `lrs` (Schaeffer, 2014). For the two last, will use `mbend::bend()` (check its documentation for details).
88
#' @param verbose Set to `FALSE` to silence the function.
9-
#' @param tol The minimum eigen values to be considered as acceptable.
9+
#' @param tol The minimum eigenvalue to be considered as acceptable.
1010
#' @param ... Other arguments to be passed to or from other functions.
1111
#'
1212
#' @examples
@@ -26,7 +26,7 @@ cor_smooth <- function(x, method = "psych", verbose = TRUE, ...) {
2626

2727

2828
#' @export
29-
cor_smooth.easycorrelation <- function(x, method = "psych", verbose = TRUE, tol = .Machine$double.eps, ...) {
29+
cor_smooth.easycorrelation <- function(x, method = "psych", verbose = TRUE, tol = 10^-12, ...) {
3030
m <- cor_smooth(as.matrix(x), method = method, verbose = verbose, tol = tol, ...)
3131
if (isTRUE(attributes(m)$smoothed)) {
3232
estim <- names(x)[names(x) %in% c("r", "rho", "tau", "D")][1]
@@ -73,7 +73,7 @@ cor_smooth.easycorrelation <- function(x, method = "psych", verbose = TRUE, tol
7373

7474

7575
#' @export
76-
cor_smooth.matrix <- function(x, method = "psych", verbose = TRUE, tol = .Machine$double.eps, ...) {
76+
cor_smooth.matrix <- function(x, method = "psych", verbose = TRUE, tol = 10^-12, ...) {
7777

7878
method <- match.arg(method, choices = c("psych", "hj", "lrs"))
7979

@@ -100,7 +100,7 @@ cor_smooth.matrix <- function(x, method = "psych", verbose = TRUE, tol = .Machin
100100

101101
#' @rdname cor_smooth
102102
#' @export
103-
is.positive_definite <- function(x, tol = .Machine$double.eps, ...) {
103+
is.positive_definite <- function(x, tol = 10^-12, ...) {
104104
UseMethod("is.positive_definite")
105105
}
106106

@@ -109,7 +109,7 @@ is.positive_definite <- function(x, tol = .Machine$double.eps, ...) {
109109
is_positive_definite <- is.positive_definite
110110

111111
#' @export
112-
is.positive_definite.matrix <- function(x, tol = .Machine$double.eps, ...) {
112+
is.positive_definite.matrix <- function(x, tol = 10^-12, ...) {
113113
eigens <- try(eigen(x), silent = TRUE)
114114

115115
# Sanity checks

R/cor_test.R

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
#' `"auto"` will attempt at selecting the most relevant method
1818
#' (polychoric when ordinal factors involved, tetrachoric when dichotomous
1919
#' factors involved, point-biserial if one dichotomous and one continuous and
20-
#' pearson otherwise).
20+
#' pearson otherwise). See below the **details** section for a desription of
21+
#' these indices.
2122
#' @param bayesian,partial_bayesian If TRUE, will run the correlations under a
2223
#' Bayesian framework. Note that for partial correlations, you will also need
2324
#' to set `partial_bayesian` to `TRUE` to obtain "full" Bayesian

R/correlation.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
#' \item **Biweight midcorrelation**: A measure of similarity that is
6060
#' median-based, instead of the traditional mean-based, thus being less
6161
#' sensitive to outliers. It can be used as a robust alternative to other
62-
#' similarity metrics, such as Pearson correlation (Langfelder \& Horvath,
62+
#' similarity metrics, such as Pearson correlation (Langfelder & Horvath,
6363
#' 2012).
6464
#'
6565
#' \item **Distance correlation**: Distance correlation measures both
@@ -78,7 +78,7 @@
7878
#' \item **Blomqvist’s coefficient**: The Blomqvist’s coefficient (also
7979
#' referred to as Blomqvist's Beta or medial correlation; Blomqvist, 1950) is a
8080
#' median-based non-parametric correlation that has some advantages over
81-
#' measures such as Spearman's or Kendall's estimates (see Shmid and Schimdt,
81+
#' measures such as Spearman's or Kendall's estimates (see Shmid & Schimdt,
8282
#' 2006).
8383
#'
8484
#' \item **Hoeffding’s D**: The Hoeffding’s D statistics is a

0 commit comments

Comments
 (0)