## 2-by-2 tables
## -------------
RCT <-
matrix(c(71, 30,
50, 100), nrow = 2, byrow = TRUE,
dimnames = list(
Diagnosis = c("Sick", "Recovered"),
Group = c("Treatment", "Control")))
RCT # note groups are COLUMNS
phi(RCT)
pearsons_c(RCT)
oddsratio(RCT)
oddsratio(RCT, alternative = "greater")
riskratio(RCT)
cohens_h(RCT)
## Larger tables
## -------------
M <-
matrix(c(150, 100, 165,
130, 50, 65,
35, 10, 2,
55, 40, 25), nrow = 4,
dimnames = list(
Music = c("Pop", "Rock", "Jazz", "Classic"),
Study = c("Psych", "Econ", "Law")))
M
cohens_w(M)
cramers_v(M)
pearsons_c(M)
## Goodness of fit
## ---------------
Smoking_ASD <- as.table(c(ASD = 17, ASP = 11, TD = 640))
normalized_chi(Smoking_ASD)
cohens_w(Smoking_ASD)
pearsons_c(Smoking_ASD)
# Use custom expected values:
normalized_chi(Smoking_ASD, p = c(0.015, 0.010, 0.975))
cohens_w(Smoking_ASD, p = c(0.015, 0.010, 0.975))
pearsons_c(Smoking_ASD, p = c(0.015, 0.010, 0.975))
## Dependent (Paired) Contingency Tables
## -------------------------------------
Performance <-
matrix(c(794, 150,
86, 570), nrow = 2,
dimnames = list(
"1st Survey" = c("Approve", "Disapprove"),
"2nd Survey" = c("Approve", "Disapprove")))
Performance
cohens_g(Performance)
Run the code above in your browser using DataLab