Example: Violent Crime and Abuse (2x2)
tab_crime <- tibble::tribble(~abuse, ~violent, ~count,
"Yes Abuse", "Yes Violet", 70,
"Yes Abuse", "No Violet", 30,
"No Abuse", "Yes Violet", 40,
"No Abuse", "No Violet", 60) %>%
tidyr::pivot_wider(names_from = violent,
values_from = count) %>%
tibble::column_to_rownames(var = "abuse") %>%
as.matrix() %>%
as.table()
tab_crime
Yes Violet No Violet
Yes Abuse 70 30
No Abuse 40 60
Pearson's Chi-squared test with Yates' continuity correction
data: .
X-squared = 16.99, df = 1, p-value = 3.758e-05
Pearson's Chi-squared test
data: .
X-squared = 18.182, df = 1, p-value = 2.008e-05
# A tibble: 1 x 4
cramers_v CI CI_low CI_high
<dbl> <dbl> <dbl> <dbl>
1 0.291 0.95 0.153 0.430
Example: Schizophrenic Treatment (Cohen textbook)
schizo_counts <- tibble::tribble(
~trt, ~response, ~n,
"Psychodynamic Therapy", "Improved", 6,
"Psychodynamic Therapy", "No Change", 6,
"Psychodynamic Therapy", "Got Worse", 8,
"Rogerian Therapy", "Improved", 4,
"Rogerian Therapy", "No Change", 14,
"Rogerian Therapy", "Got Worse", 2,
"Group Therapy", "Improved", 8,
"Group Therapy", "No Change", 3,
"Group Therapy", "Got Worse", 9,
"Token Economy", "Improved", 12,
"Token Economy", "No Change", 5,
"Token Economy", "Got Worse", 3)
schizo_counts
# A tibble: 12 x 3
trt response n
<chr> <chr> <dbl>
1 Psychodynamic Therapy Improved 6
2 Psychodynamic Therapy No Change 6
3 Psychodynamic Therapy Got Worse 8
4 Rogerian Therapy Improved 4
5 Rogerian Therapy No Change 14
6 Rogerian Therapy Got Worse 2
7 Group Therapy Improved 8
8 Group Therapy No Change 3
9 Group Therapy Got Worse 9
10 Token Economy Improved 12
11 Token Economy No Change 5
12 Token Economy Got Worse 3
# A tibble: 9 x 3
id trt response
<chr> <chr> <chr>
1 1 Psychodynamic Therapy Improved
2 2 Psychodynamic Therapy Improved
3 3 Psychodynamic Therapy Improved
4 4 Psychodynamic Therapy Improved
5 ... <NA> <NA>
6 77 Token Economy No Change
7 78 Token Economy Got Worse
8 79 Token Economy Got Worse
9 80 Token Economy Got Worse
response
trt Got Worse Improved No Change Total
Group Therapy 9 8 3 20
Psychodynamic Therapy 8 6 6 20
Rogerian Therapy 2 4 14 20
Token Economy 3 12 5 20
Total 22 30 28 80
---------------------------------------------------------------------------------
Treatment Group
Group Therapy Psychodynamic Therapy Rogerian Therapy
n = 20 n = 20 n = 20
Six Months
Got Worse 9 (45%) 8 (40%) 2 (10%)
Improved 8 (40%) 6 (30%) 4 (20%)
No Change 3 (15%) 6 (30%) 14 (70%)
Token Economy
n = 20
3 (15%)
12 (60%)
5 (25%)
---------------------------------------------------------------------------------
|
n = 20 |
n = 20 |
n = 20 |
n = 20 |
|
Six Months |
|
|
|
|
0.002 |
Got Worse |
9 (45%) |
8 (40%) |
2 (10%) |
3 (15%) |
|
Improved |
8 (40%) |
6 (30%) |
4 (20%) |
12 (60%) |
|
No Change |
3 (15%) |
6 (30%) |
14 (70%) |
5 (25%) |
|
trt
response Group Therapy Psychodynamic Therapy Rogerian Therapy Token Economy
Got Worse 9 8 2 3
Improved 8 6 4 12
No Change 3 6 14 5
Sum 20 20 20 20
trt
response Sum
Got Worse 22
Improved 30
No Change 28
Sum 80
Pearson's Chi-squared test
data: .
X-squared = 21.394, df = 6, p-value = 0.001558
trt
response Group Therapy Psychodynamic Therapy Rogerian Therapy Token Economy
Got Worse 1.4924050 1.0660036 -1.4924050 -1.0660036
Improved 0.1825742 -0.5477226 -1.2780193 1.6431677
No Change -1.5118579 -0.3779645 2.6457513 -0.7559289
# A tibble: 1 x 4
cramers_v CI CI_low CI_high
<dbl> <dbl> <dbl> <dbl>
1 0.366 0.95 0.145 0.483