Skip to content

Instantly share code, notes, and snippets.

@m-Py
Created July 4, 2022 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m-Py/8b7119fda6f45de8533bafd2b37c87b0 to your computer and use it in GitHub Desktop.
Save m-Py/8b7119fda6f45de8533bafd2b37c87b0 to your computer and use it in GitHub Desktop.
# compare Cohen's h and phi coefficient as effect sizes for comparing proportions
library(effectsize)
# test data (have to be contingency tables; one column is always the same)
matrices <- lapply(1:999, function(i) matrix(c(i, 1000-i, 999, 1), ncol = 2))
phis <- sapply(matrices, function(x) effectsize::phi(x)$phi)
hs <- sapply(matrices, function(x) effectsize::cohens_h(x)$Cohens_h)
plot(abs(hs), phis, type = "l")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment