Computes the local and global Percentages of Maximum Deviation from Independence (pem) of a contingency table.

pem.table(x, y, weights = NULL, sort = FALSE, na.rm = FALSE, na.value = "NAs", digits = 1)

Arguments

x

the first categorical variable

y

the second categorical variable

weights

an optional numeric vector of weights (by default, a vector of 1 for uniform weights)

sort

logical. Whether rows and columns are sorted according to a correspondence analysis or not (default is FALSE).

na.rm

logical, indicating whether NA values should be silently removed before the computation proceeds. If FALSE (default), an additional level is added to the variables (see na.value argument).

na.value

character. Name of the level for NA category. Default is "NAs". Only used if na.rm = FALSE.

digits

integer. The number of digits (default is 1). If NULL, the results are not rounded.

Details

The Percentage of Maximum Deviation from Independence (pem) is an association measure for contingency tables and also provides attraction (resp. repulsion) measures in each cell of the crosstabulation (see Cibois, 1993). It is an alternative to khi2, Cramer's V coefficient, etc.

Value

Returns a list:

peml

Table with local percentages of maximum deviation from independence

pemg

Numeric value, i.e. the global percentage of maximum deviation from independence

References

Cibois P., 1993, Le pem, pourcentage de l'ecart maximum : un indice de liaison entre modalites d'un tableau de contingence, Bulletin de methodologie sociologique, n40, p.43-63. https://cibois.pagesperso-orange.fr/bms93.pdf

Author

Nicolas Robette

Examples

data(Movies)
pem.table(Movies$Country, Movies$ArtHouse)
#> $peml
#>         y
#> x           No   Yes
#>   Europe   5.7  -5.7
#>   France -51.6  51.6
#>   Other  -55.1  55.1
#>   USA     72.3 -72.3
#> 
#> $pemg
#> [1] 64
#>