Learn R Programming

misty (version 0.5.0)

cor.cont: Pearson's Contingency Coefficient

Description

This function computes the (adjusted) Pearson's contingency coefficient between two or more than two variables.

Usage

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

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

Arguments

x

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

adjust

logical: if TRUE, the adjusted contingency coefficient (i.e., Sakoda's adjusted Pearson's C) is computed.

tri

a character string 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 contingency coefficients.

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.

Author

Takuya Yanagida takuya.yanagida@univie.ac.at

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

Details

The maximum contingency coefficient is determined by the distribution of the two variables, i.e., the contingency coefficient cannot achieve the value of 1 in many cases. According to Sakoda (1977), the contingency coefficient can be adjusted by relating the coefficient to the possible maximum, \(C / C_max\).

References

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

Sakoda, J.M. (1977). Measures of association for multivariate contingency tables. Proceedings of the Social Statistics Section of the American Statistical Association (Part III), 777-780.

Examples

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

# Contingency coefficient between x and y
cor.cont(dat[, c("x", "y")])

# Adjusted contingency coefficient between x and y
cor.cont(dat[, c("x", "y")], adjust = TRUE)

# Contingency coefficient matrix between x, y, and z
cor.cont(dat)

# Adjusted contingency coefficient matrix between x, y, and z
cor.cont(dat, adjust = TRUE)

Run the code above in your browser using DataLab