auto.correlate: Automatic correlations

View source: R/auto.correlate.R

auto.correlateR Documentation

Automatic correlations

Description

This wrapper is similar to cor_auto. There are some minor adjustments that make this function simpler and to function within EGAnet. NA values are not treated as categories (this behavior differs from cor_auto)

Usage

auto.correlate(
  data,
  corr = c("kendall", "pearson", "spearman"),
  ordinal.categories = 7,
  forcePD = TRUE,
  na.data = c("pairwise", "listwise"),
  empty.method = c("none", "zero", "all"),
  empty.value = c("none", "point_five", "one_over"),
  verbose = FALSE,
  ...
)

Arguments

data

Matrix or data frame. Should consist only of variables to be used in the analysis

corr

Character (length = 1). The standard correlation method to be used. Defaults to "pearson". Using "pearson" will compute polychoric, tetrachoric, polyserial, and biserial correlations for categorical and categorical/continuous correlations by default. To obtain "pearson" correlations regardless, use cor. Other options of "kendall" and "spearman" are provided for completeness and use cor

ordinal.categories

Numeric (length = 1). Up to the number of categories before a variable is considered continuous. Defaults to 7 categories before 8 is considered continuous

forcePD

Boolean (length = 1). Whether positive definite matrix should be enforced. Defaults to TRUE

na.data

Character (length = 1). How should missing data be handled? Defaults to "pairwise". Available options:

  • "pairwise" — Computes correlation for all available cases between two variables

  • "listwise" — Computes correlation for all complete cases in the dataset

empty.method

Character (length = 1). Method for empty cell correction in polychoric.matrix. Defaults to "none" Available options:

  • "none" — Adds no value (empty.value = "none") to the empirical joint frequency table between two variables

  • "zero" — Adds empty.value to the cells with zero in the joint frequency table between two variables

  • "all" — Adds empty.value to all in the joint frequency table between two variables

empty.value

Character (length = 1). Value to add to the joint frequency table cells in polychoric.matrix. Defaults to "none". Accepts numeric values between 0 and 1 or specific methods:

  • "none" — Adds no value (0) to the empirical joint frequency table between two variables

  • "point_five" — Adds 0.5 to the cells defined by empty.method

  • "one_over" — Adds 1 / n where n equals the number of cells based on empty.method. For empty.method = "zero", n equals the number of zero cells

verbose

Boolean (length = 1). Whether messages should be printed. Defaults to FALSE

...

Not actually used but makes it easier for general functionality in the package

Author(s)

Alexander P. Christensen <alexpaulchristensen@gmail.com>

Examples

# Load data
wmt <- wmt2[,7:24]

# Obtain correlations
wmt_corr <- auto.correlate(wmt)


EGAnet documentation built on Nov. 18, 2023, 1:07 a.m.