cramersV.test: Test Cramer's V for Statistical Significance

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Calculates the Cramer's V measure of correlation between x and y and the statistical significance of this correlation.

Usage

1
  cramersV.test(x, y, na.rm=TRUE)

Arguments

x

A vector of factor, character, logical or numeric values.

y

A vector of factor, character, logical or numeric values.

na.rm

If TRUE (default) records with a missing value of x or y are removed before applying the test; if FALSE, then the value of Cramer's V is set to NA if there are one or missing x or y values.

Details

If either x or y is supplied as a non-factor variable, and has <= 20 unique values, then it is converted into a factor to allow the value of Cramer's V and its significance to be calculated. If x or y is a non-factor variable with > 20 unique values then Cramer's V is not calculated and a value of NA is returned.

Value

A data frame returning two values:

cramers.v

The Cramer's V measure of correlation between x and y

p.value

The statistical significance of the observed correlation

Author(s)

Paul Williamson

See Also

cramersV; cramersV.results

Examples

1
2
3
4
5
6
7
8
## Compare two factor variables
cramersV.test(survey$Tenure, survey$Age)

## Include a non-factor variable (income) with <= 20 unique values
cramersV.test(survey$Tenure[1:20], survey$Income[1:20])

## Include a non-factor variable (income) with > 20 unique values
cramersV.test(survey$Tenure, survey$Income)

DrPaulWilliamson/ENVS450 documentation built on May 9, 2019, 3:23 a.m.