Learn R Programming

effectsize (version 0.4.0)

phi: Effect size for contingency tables

Description

Compute Cramer's V, phi (\(\phi\)), Cohen's w (an alias of phi) and Cohen's g for contingency tables or goodness-of-fit. See details.

Usage

phi(x, y = NULL, ci = 0.95, adjust = FALSE, CI, ...)

cohens_w(x, y = NULL, ci = 0.95, adjust = FALSE, CI, ...)

cramers_v(x, y = NULL, ci = 0.95, adjust = FALSE, CI, ...)

cohens_g(x, y = NULL, ci = 0.95, ...)

Arguments

x

a numeric vector or matrix. x and y can also both be factors.

y

a numeric vector; ignored if x is a matrix. If x is a factor, y should be a factor of the same length.

ci

Confidence Interval (CI) level

adjust

Should the effect size be bias-corrected? Defaults to FALSE.

CI

Deprecated in favor of ci.

...

Arguments passed to stats::chisq.test(), such as p. Ignored for cohens_g().

Value

A data frame with the effect size(s), and confidence interval(s).

Details

Cramer's V and phi (\(\phi\)) are effect sizes for tests of independence in 2D contingency tables, or for goodness-of-fit in 1D tables. For 2x2 tables, all 3 are identical, and are equal to the simple correlation between two dichotomous variables, ranging between 0 (no dependence) and 1 (perfect dependence). For larger tables, Cramer's V should be used, as it is bounded between 0-1, whereas phi can be larger than 1.

Cohen's g is an effect size for dependent (paired) contingency tables ranging between 0 (perfect symmetry) and 0.5 (perfect asymmetry) (see stats::mcnemar.test()).

Confidence Intervals

For Cramer's V and phi, confidence intervals are estimated using the Noncentrality parameter method; These methods searches for a the best ncp (non-central parameters) for of the noncentral Chi-squared distribution for the desired tail-probabilities, and then convert these ncps to the corresponding effect sizes.

For Cohen's g, confidence intervals are based on the proportion (\(P = g + 0.5\)) confidence intervals returned by stats::prop.test() (minus 0.5), which give a good close approximation.

References

  • Cohen, J. (1988). Statistical power analysis for the behavioural sciences.

See Also

chisq_to_phi() for details regarding estimation and CIs.

Examples

Run this code
# NOT RUN {
M <- rbind(c(150, 130, 35, 55),
           c(100, 50,  10, 40),
           c(165, 65,  2,  25))

dimnames(M) <- list(Study = c("Psych", "Econ", "Law"),
                    Music = c("Pop", "Rock", "Jazz", "Classic"))
M

phi(M)

cramers_v(M)


Performance <-
  matrix(c(794, 86, 150, 570),
         nrow = 2,
         dimnames = list("1st Survey" = c("Approve", "Disapprove"),
                         "2nd Survey" = c("Approve", "Disapprove")))

cohens_g(Performance)

# }

Run the code above in your browser using DataLab