cor.cramer: Cramer's V

View source: R/cor.cramer.R

cor.cramerR Documentation

Cramer's V

Description

This function computes the (bias-corrected) Cramer's V between two or more than two variables.

Usage

cor.cramer(x, correct = TRUE, tri = c("both", "lower", "upper"), digits = 2,
           as.na = NULL, check = TRUE, output = TRUE)

Arguments

x

a matrix or data frame with integer vectors, character vectors or factors.

correct

logical: if TRUE (default), the bias-corrected Cramer's V is computed.

tri

a character string or character vector indicating which triangular of the matrix to show on the console, i.e., both for upper and lower triangular, lower (default) for the lower triangular, and upper for the upper triangular.

digits

an integer value indicating the number of decimal places digits to be used for displaying Cramer's V.

as.na

a numeric vector indicating user-defined missing values, i.e. these values are converted to NA before conducting the analysis.

check

logical: if TRUE, argument specification is checked.

output

logical: if TRUE, output is shown on the console.

Details

Cramer's V can have large bias tending to overestimate the strength of association which depends on the size of the table and the sample size. As proposed by Bergsma (2013) a bias correction can be applied to obtain the bias-corrected Cramer's V.

Value

Returns an object of class misty.object, which is a list with following entries:

call

function call

type

type of analysis

data

matrix or data frame specified in x

args

specification of function arguments

result

result table

Author(s)

Takuya Yanagida takuya.yanagida@univie.ac.at

References

Rasch, D., Kubinger, K. D., & Yanagida, T. (2011). Statistics in psychology - Using R and SPSS. John Wiley & Sons.

Bergsma, W. (2013). A bias correction for Cramer's V and Tschuprow's T. Journal of the Korean Statistical Society, 42, 323-328. https://doi.org/10.1016/j.jkss.2012.10.002

See Also

cor.matrix, cor.cont, cor.phi, cor.poly, cohens.d.

Examples

dat <- data.frame(x = c(1, 1, 2, 1, 3, 3, 2, 2, 1, 2),
                  y = c(1, 2, 2, 1, 3, 4, 1, 2, 3, 1),
                  z = c(1, 1, 2, 1, 2, 3, 1, 2, 3, 2))

# Bias-corrected Cramer's V between x and y
cor.cramer(dat[, c("x", "y")])

# Cramer's V between x and y
cor.cramer(dat[, c("x", "y")], correct = FALSE)

# Bias-corrected Cramer's V matrix between x, y, and z
cor.cramer(dat[, c("x", "y", "z")])

# Cramer's V matrix between x, y, and z
cor.cramer(dat[, c("x", "y", "z")], correct = FALSE)

misty documentation built on Nov. 15, 2023, 1:06 a.m.

Related to cor.cramer in misty...