|
9 | 9 | # report_effectsize ---------------------
|
10 | 10 |
|
11 | 11 | .report_effectsize_chi2 <- function(x, table, dot_args, rules = "funder2019") {
|
12 |
| - if (chi2_type(x) %in% c("pearson", "probabilities")) { |
13 |
| - args <- c(list(x), dot_args) |
14 |
| - table <- do.call(effectsize::effectsize, args) |
15 |
| - table_footer <- attributes(table)$table_footer |
16 |
| - ci <- attributes(table)$ci |
17 |
| - estimate <- names(table)[1] |
18 |
| - rules <- ifelse(is.null(dot_args$rules), rules, dot_args$rules) |
19 |
| - |
20 |
| - args <- c(list(table, rules = rules), dot_args) |
21 |
| - interpretation <- do.call(effectsize::interpret, args)$Interpretation |
22 |
| - rules <- .text_effectsize(attr(attr(interpretation, "rules"), "rule_name")) |
23 |
| - } else { |
24 |
| - stop(insight::format_message( |
| 12 | + if (!chi2_type(x) %in% c("pearson", "probabilities")) { |
| 13 | + insight::format_error( |
25 | 14 | "This test is not yet supported. Please open an issue at {.url https://github.com/easystats/report/issues}."
|
26 |
| - ), call. = FALSE) |
27 |
| - } |
28 |
| - |
29 |
| - if (estimate == "Cramers_v_adjusted") { |
30 |
| - main <- paste0("Adjusted Cramer's v = ", insight::format_value(table[[estimate]])) |
31 |
| - } else if (estimate == "Fei") { |
32 |
| - main <- paste0("Fei = ", insight::format_value(table[[estimate]])) |
33 |
| - } else if (estimate == "Tschuprows_t") { |
34 |
| - main <- paste0("Tschuprow's t = ", insight::format_value(table[[estimate]])) |
35 |
| - } else if (estimate == "Tschuprows_t_adjusted") { |
36 |
| - main <- paste0("Adjusted Tschuprow's t = ", insight::format_value(table[[estimate]])) |
37 |
| - } else if (estimate == "Pearsons_c") { |
38 |
| - main <- paste0("Pearson's c = ", insight::format_value(table[[estimate]])) |
39 |
| - } else if (estimate == "phi_adjusted") { |
40 |
| - main <- paste0("Adjusted Phi = ", insight::format_value(table[[estimate]])) |
41 |
| - } else if (estimate == "Cohens_h") { |
42 |
| - main <- paste0("Cohen's h = ", insight::format_value(table[[estimate]])) |
43 |
| - } else if (estimate == "Odds_ratio") { |
44 |
| - main <- paste0("Odds ratio = ", insight::format_value(table[[estimate]])) |
45 |
| - } else if (estimate == "Ris_kratio") { |
46 |
| - main <- paste0("Risk ratio = ", insight::format_value(table[[estimate]])) |
47 |
| - } else if (estimate == "cohens_h") { |
48 |
| - main <- paste0("Cohen's w = ", insight::format_value(table[[estimate]])) |
49 |
| - } else { |
50 |
| - main <- paste0(estimate, " = ", insight::format_value(table[[estimate]])) |
| 15 | + ) |
51 | 16 | }
|
| 17 | + es_args <- c(list(x), dot_args) |
| 18 | + table <- do.call(effectsize::effectsize, es_args) |
| 19 | + table_footer <- attributes(table)$table_footer |
| 20 | + ci <- attributes(table)$ci |
| 21 | + estimate <- names(table)[1] |
| 22 | + rules <- ifelse(is.null(dot_args$rules), rules, dot_args$rules) |
| 23 | + |
| 24 | + es_args <- c(list(table, rules = rules), dot_args) |
| 25 | + interpretation <- do.call(effectsize::interpret, es_args)$Interpretation |
| 26 | + rules <- .text_effectsize(attr(attr(interpretation, "rules"), "rule_name")) |
| 27 | + |
| 28 | + main <- switch(estimate, |
| 29 | + Cramers_v_adjusted = paste0("Adjusted Cramer's v = ", insight::format_value(table[[estimate]])), |
| 30 | + Fei = paste0("Fei = ", insight::format_value(table[[estimate]])), |
| 31 | + Tschuprows_t = paste0("Tschuprow's t = ", insight::format_value(table[[estimate]])), |
| 32 | + Tschuprows_t_adjusted = paste0("Adjusted Tschuprow's t = ", insight::format_value(table[[estimate]])), |
| 33 | + Pearsons_c = paste0("Pearson's c = ", insight::format_value(table[[estimate]])), |
| 34 | + phi_adjusted = paste0("Adjusted Phi = ", insight::format_value(table[[estimate]])), |
| 35 | + Cohens_h = paste0("Cohen's h = ", insight::format_value(table[[estimate]])), |
| 36 | + Odds_ratio = paste0("Odds ratio = ", insight::format_value(table[[estimate]])), |
| 37 | + Ris_kratio = paste0("Risk ratio = ", insight::format_value(table[[estimate]])), |
| 38 | + cohens_h = paste0("Cohen's w = ", insight::format_value(table[[estimate]])), |
| 39 | + paste0(estimate, " = ", insight::format_value(table[[estimate]])) |
| 40 | + ) |
52 | 41 |
|
53 | 42 | statistics <- paste0(
|
54 | 43 | main,
|
|
79 | 68 | vars_full <- paste0(names(attributes(x$observed)$dimnames), collapse = " and ")
|
80 | 69 | } else if (chi2_type(x) == "probabilities") {
|
81 | 70 | type <- " / goodness of fit of "
|
82 |
| - dist <- ifelse( |
| 71 | + distr <- ifelse( |
83 | 72 | grepl("non", attr(table, "table_footer"), fixed = TRUE), "a uniform distribution",
|
84 | 73 | paste0("a distribution of [", paste0(
|
85 | 74 | names(x$expected), ": n=", x$expected,
|
86 | 75 | collapse = ", "
|
87 | 76 | ), "]")
|
88 | 77 | )
|
89 | 78 |
|
90 |
| - vars_full <- paste(x$data.name, "to", dist) |
| 79 | + vars_full <- paste(x$data.name, "to", distr) |
91 | 80 | }
|
92 | 81 |
|
93 |
| - text <- paste0( |
| 82 | + paste0( |
94 | 83 | trimws(x$method),
|
95 | 84 | type,
|
96 | 85 | paste0(" ", vars_full)
|
97 | 86 | )
|
98 |
| - |
99 |
| - text |
100 | 87 | }
|
101 | 88 |
|
102 | 89 | chi2_type <- function(x) {
|
|
0 commit comments