diff --git a/DESCRIPTION b/DESCRIPTION index 395f81c8..591bbb4d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: EGAnet Title: Exploratory Graph Analysis – a Framework for Estimating the Number of Dimensions in Multivariate Data using Network Psychometrics -Version: 2.0.5 -Date: 2024-03-14 +Version: 2.0.6 +Date: 2024-03-16 Authors@R: c(person("Hudson", "Golino", email = "hfg9s@virginia.edu", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-1601-1447")), person("Alexander", "Christensen", email = "alexpaulchristensen@gmail.com", role = "aut", comment = c(ORCID = "0000-0002-9798-7037")), person("Robert", "Moulder", email = "rgm4fd@virginia.edu", role = "ctb", comment = c(ORCID = "0000-0001-7504-9560")), @@ -11,15 +11,15 @@ Authors@R: c(person("Hudson", "Golino", email = "hfg9s@virginia.edu", role = c(" Maintainer: Hudson Golino Description: Implements the Exploratory Graph Analysis (EGA) framework for dimensionality and psychometric assessment. EGA estimates the number of dimensions in - psychological data using network estimation methods and community detection + psychological data using network estimation methods and community detection algorithms. A bootstrap method is provided to assess the stability of dimensions - and items. Fit is evaluated using the Entropy Fit family of indices. Unique + and items. Fit is evaluated using the Entropy Fit family of indices. Unique Variable Analysis evaluates the extent to which items are locally dependent (or redundant). Network loadings provide similar information to factor loadings and - can be used to compute network scores. A bootstrap and permutation approach are + can be used to compute network scores. A bootstrap and permutation approach are available to assess configural and metric invariance. Hierarchical structures can be detected using Hierarchical EGA. Time series and intensive longitudinal - data can be analyzed using Dynamic EGA, supporting individual, group, and + data can be analyzed using Dynamic EGA, supporting individual, group, and population level assessments. Depends: R (>= 3.5.0) License: GPL (>= 3.0) diff --git a/NEWS b/NEWS index 989773d2..e886cfe6 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,10 @@ WEBSITE: https://r-ega.net +Changes in version 2.0.6 + +o FIX: bug when using `na.data = "listwise"` in standard `cor()` function + + Changes in version 2.0.5 o FIX: 'stroke' parameter in `hierEGA` that broke with {ggplot2} update diff --git a/R/auto.correlate.R b/R/auto.correlate.R index ecec46a1..d7f9c7ea 100644 --- a/R/auto.correlate.R +++ b/R/auto.correlate.R @@ -97,7 +97,7 @@ #' @export #' # Automatic correlations ---- -# Updated 07.09.2023 +# Updated 16.03.2024 auto.correlate <- function( data, # Matrix or data frame corr = c("kendall", "pearson", "spearman"), # allow changes to standard correlations @@ -140,8 +140,11 @@ auto.correlate <- function( # Obtain correlation matrix correlation_matrix <- cor( - x = data, use = na.data, - method = corr + x = data, use = swiftelse( + na.data == "pairwise", + "pairwise.complete.obs", + "complete.obs" + ), method = corr ) }else{ # Proceed with determination of categorical correlations @@ -191,7 +194,11 @@ auto.correlate <- function( continuous_variables, continuous_variables # ensure proper indexing ] <- cor( x = data[,continuous_variables], - use = na.data, method = corr + use = swiftelse( + na.data == "pairwise", + "pairwise.complete.obs", + "complete.obs" + ), method = corr ) } @@ -222,8 +229,11 @@ auto.correlate <- function( # Compute Pearson's correlations correlation_matrix <- cor( - x = data, use = na.data, - method = corr + x = data, use = swiftelse( + na.data == "pairwise", + "pairwise.complete.obs", + "complete.obs" + ), method = corr ) } @@ -357,7 +367,7 @@ auto.correlate_errors <- function(data, ordinal.categories, forcePD, verbose, .. #' Uses two-step approximation from {polycor}'s \code{polyserial} #' #' @noRd -# Updated 03.07.2023 +# Updated 16.03.2024 polyserial.vector <- function( categorical_variable, continuous_variables, na.data = c("pairwise", "listwise") @@ -388,7 +398,14 @@ polyserial.vector <- function( sqrt((categorical_cases - 1) / categorical_cases) * sd(categorical_variable, na.rm = TRUE) * # Correlations with scaled continuous variables - cor(categorical_variable, scale(continuous_variables), use = na.data) / + cor( + categorical_variable, scale(continuous_variables), + use = swiftelse( + na.data == "pairwise", + "pairwise.complete.obs", + "complete.obs" + ) + ) / # Compute sum of thresholds sum(dnorm(obtain_thresholds(categorical_variable)), na.rm = TRUE) ) diff --git a/R/helpers.R b/R/helpers.R index 4d8bc53d..6aa6db3e 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -1448,7 +1448,7 @@ needs_usable <- function(ellipse) #' @noRd # Obtain data, sample size, correlation matrix ---- # Generic function to get the usual needed inputs -# Updated 04.09.2023 +# Updated 16.03.2024 obtain_sample_correlations <- function(data, n, corr, na.data, verbose, ...) { @@ -1501,7 +1501,13 @@ obtain_sample_correlations <- function(data, n, corr, na.data, verbose, ...) ) }else{ - correlation_matrix <- cor(data, use = na.data, method = corr) + correlation_matrix <- cor( + data, use = swiftelse( + na.data == "pairwise", + "pairwise.complete.obs", + "complete.obs" + ), method = corr + ) } }