effsize {misty}R Documentation

Effect Sizes for Categorical Variables

Description

This function computes effect sizes for one or more than one categorical variable, i.e., (adjusted) phi coefficient, (bias-corrected) Cramer's V, (bias-corrected) Tschuprow's T, (adjusted) Pearson's contingency coefficient, Cohen's w), and Fei. By default, the function computes Fei based on a chi-square goodness-of-fit test for one categorical variable, phi coefficient based on a chi-square test of independence for two dichotomous variables, and Cramer's V based on a chi-square test of independence for two variables with at least one polytomous variable.

Usage

effsize(..., data = NULL, type = c("phi", "cramer", "tschuprow", "cont", "w", "fei"),
        alternative = c("two.sided", "less", "greater"),   conf.level = 0.95,
        adjust = TRUE, indep = TRUE, p = NULL, digits = 3, as.na = NULL,
        write = NULL, append = TRUE, check = TRUE, output = TRUE)

Arguments

...

a vector, factor, matrix or data frame. Alternatively, an expression indicating the variable names in data e.g., as.na(x1, x2, data = dat). When specifying more than one variable, the first variable is always the focal variable in the Chi-square test of independence which association with all other variables is investigated. Note that the operators ., +, -, ~, :, ::, and ! can also be used to select variables, see 'Details' in the df.subset function.

data

a data frame when specifying one or more variables in the argument .... Note that the argument is NULL when specifying a vector, factor, matrix, array, data frame, or list for the argument ....

type

a chracter string indicating the type of effect size, i.e., phi for phi coefficient, cramer for Cramer's V, tschuprow for Tschuprow’s T, cont for Pearson's contingency coefficient, w for Cohen's w, and Fei for Fei.

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less".

conf.level

a numeric value between 0 and 1 indicating the confidence level of the interval.

adjust

logical: if TRUE (default), phi coefficient and Pearson's contingency coefficient are adjusted by relating the coefficient to the possible maximum, or Cramer's V and Tschuprow’s T are corrected for small-sample bias.

indep

logical: if TRUE, effect size computation is based on a chi-square test of independence (default when specifying two variable in ...), if FALSE effect size computation is based on a chi-square goodness-of-fit test (default when specifying one variable in ...).

p

a numeric vector specifying the expected proportions in each category of the categorical variable when conduting a chi-square goodness-of-fit test. By default, the expected proportions in each category are assumed to be equal.

digits

an integer value indicating the number of decimal places digits to be used for displaying the results.

as.na

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

write

a character string naming a file for writing the output into either a text file with file extension ".txt" (e.g., "Output.txt") or Excel file with file extention ".xlsx" (e.g., "Output.xlsx"). If the file name does not contain any file extension, an Excel file will be written.

append

logical: if TRUE (default), output will be appended to an existing text file with extension .txt specified in write, if FALSE existing text file will be overwritten.

check

logical: if TRUE (default), argument specification is checked.

output

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

Note

This function is based on modified copies of the functions chisq_to_phi, chisq_to_cramers_v, chisq_to_tschuprows_t, chisq_to_pearsons_c, chisq_to_cohens_w, and chisq_to_fei from the effectsize package (Ben-Shachar, Lüdecke & Makowski, 2020).

Author(s)

Takuya Yanagida takuya.yanagida@univie.ac.at

References

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

Ben-Shachar M. S., Lüdecke D., Makowski D. (2020). effectsize: Estimation of Effect Size Indices and Standardized Parameters. Journal of Open Source Software, 5 (56), 2815. https://doi.org/10.21105/joss.02815

Ben-Shachar, M. S., Patil, I., Theriault, R., Wiernik, B. M., Lüdecke, D. (2023). Phi, Fei, Fo, Fum: Effect sizes for categorical data that use the chi-squared statistic. Mathematics, 11, 1982. https://doi.org/10.3390/math11091982

Cureton, E. E. (1959). Note on Phi/Phi max. Psychometrika, 24, 89-91.

Davenport, E. C., & El-Sanhurry, N. A. (1991). Phi/Phimax: Review and synthesis. Educational and Psychological Measurement, 51, 821-828. https://doi.org/10.1177/001316449105100403

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.

See Also

cor.matrix, cohens.d

Examples

# Example 1a: Phi coefficient for 'vs' and 'am'
effsize(mtcars[, c("vs", "am")])

# Example 1a: Alternative specification using the 'data' argument
effsize(vs, am, data = mtcars)

# Example 2: Bias-corrected Cramer's V for 'gear' and 'carb'
effsize(gear, carb, data = mtcars)

# Example 3: Cramer's V (without bias-correction) for 'gear' and 'carb'
effsize(gear, carb, data = mtcars, adjust = FALSE)

# Example 4: Adjusted Pearson's contingency coefficient for 'gear' and 'carb'
effsize(gear, carb, data = mtcars, type = "cont")

# Example 5: Fei for 'gear'
effsize(gear, data = mtcars)

# Example 6a: Bias-corrected Cramer's V for 'cyl' and 'vs', 'am', 'gear', and 'carb'
effsize(mtcars[, c("cyl", "vs", "am", "gear", "carb")])

# Example 6b: Alternative specification using the 'data' argument
effsize(cyl, vs:carb, data = mtcars)

## Not run: 
# Example 7b: Write Results into a text file
effsize(cyl, vs:carb, data = mtcars, write = "Cramer.txt")

# Example 7b: Write Results into a Excel file
effsize(cyl, vs:carb, data = mtcars, write = "Cramer.xlsx")

## End(Not run)

[Package misty version 0.6.3 Index]