|
12 | 12 | #' library(BayesFactor)
|
13 | 13 | #'
|
14 | 14 | #' rez <- BayesFactor::ttestBF(iris$Sepal.Width, iris$Sepal.Length)
|
15 |
| -#' report_statistics(rez, exact=TRUE) # Print exact BF |
16 |
| -#' report(rez, h0="the null hypothesis", h1="the alternative") |
| 15 | +#' report_statistics(rez, exact = TRUE) # Print exact BF |
| 16 | +#' report(rez, h0 = "the null hypothesis", h1 = "the alternative") |
17 | 17 | #'
|
18 | 18 | #' rez <- BayesFactor::correlationBF(iris$Sepal.Width, iris$Sepal.Length)
|
19 | 19 | #' report(rez)
|
20 | 20 | #' }
|
21 | 21 | #'
|
22 | 22 | #' @export
|
23 |
| -report.BFBayesFactor <- function(x, h0="H0", h1="H1", ...) { |
24 |
| - if ("BFlinearModel" %in% class(x@numerator[[1]])) { |
| 23 | +report.BFBayesFactor <- function(x, h0 = "H0", h1 = "H1", ...) { |
| 24 | + if (inherits("BFlinearModel", class(x@numerator[[1]]))) { |
25 | 25 | return(report(bayestestR::bayesfactor_models(x), ...))
|
26 | 26 | }
|
27 | 27 |
|
28 | 28 | if (length(x@numerator) > 1) {
|
29 |
| - insight::format_alert("Multiple `BFBayesFactor` models detected - reporting for the first numerator model.", |
30 |
| - "See help(\"get_parameters\", package = \"insight\").") |
| 29 | + insight::format_alert( |
| 30 | + "Multiple `BFBayesFactor` models detected - reporting for the first numerator model.", |
| 31 | + "See help(\"get_parameters\", package = \"insight\")." |
| 32 | + ) |
31 | 33 | x <- x[1]
|
32 | 34 | }
|
33 | 35 |
|
34 | 36 | param <- parameters::parameters(x[1], ...)
|
35 | 37 | bf <- param$BF
|
36 |
| - dir <- ifelse(bf < 1, "h0", "h1") |
| 38 | + other_dir <- ifelse(bf < 1, "h0", "h1") |
37 | 39 |
|
38 | 40 |
|
39 |
| - if (dir == "h1") { |
40 |
| - text <- paste0("There is ", |
41 |
| - effectsize::interpret_bf(bf, ...), |
42 |
| - " ", |
43 |
| - h1, |
44 |
| - " over ", |
45 |
| - h0, |
46 |
| - " (", report_statistics(x, ...), ").") |
| 41 | + if (other_dir == "h1") { |
| 42 | + other_text <- paste0( |
| 43 | + "There is ", |
| 44 | + effectsize::interpret_bf(bf, ...), |
| 45 | + " ", |
| 46 | + h1, |
| 47 | + " over ", |
| 48 | + h0, |
| 49 | + " (", report_statistics(x, ...), ")." |
| 50 | + ) |
47 | 51 | } else {
|
48 |
| - text <- paste0("There is ", |
49 |
| - effectsize::interpret_bf(1/bf, ...), |
50 |
| - " ", |
51 |
| - h0, |
52 |
| - " over ", |
53 |
| - h1, |
54 |
| - " (", report_statistics(x, ...), ").") |
| 52 | + other_text <- paste0( |
| 53 | + "There is ", |
| 54 | + effectsize::interpret_bf(1 / bf, ...), |
| 55 | + " ", |
| 56 | + h0, |
| 57 | + " over ", |
| 58 | + h1, |
| 59 | + " (", report_statistics(x, ...), ")." |
| 60 | + ) |
55 | 61 | }
|
56 |
| - text |
| 62 | + other_text |
57 | 63 | }
|
58 | 64 |
|
59 | 65 |
|
60 | 66 |
|
61 | 67 | #' @rdname report.BFBayesFactor
|
62 | 68 | #' @export
|
63 | 69 | report_statistics.BFBayesFactor <- function(x, table = NULL, ...) {
|
64 |
| - if(is.null(table)) { |
| 70 | + if (is.null(table)) { |
65 | 71 | if (length(x@numerator) > 1) {
|
66 |
| - insight::format_alert("Multiple `BFBayesFactor` models detected - reporting for the first numerator model.", |
67 |
| - "See help(\"get_parameters\", package = \"insight\").") |
| 72 | + insight::format_alert( |
| 73 | + "Multiple `BFBayesFactor` models detected - reporting for the first numerator model.", |
| 74 | + "See help(\"get_parameters\", package = \"insight\")." |
| 75 | + ) |
68 | 76 | x <- x[1]
|
69 | 77 | }
|
70 | 78 | table <- parameters::parameters(x, ...)
|
71 | 79 | }
|
72 | 80 |
|
73 | 81 | bf <- table$BF
|
74 |
| - text <- ifelse(bf < 1, |
75 |
| - insight::format_bf(1/bf, name="BF01", ...), |
76 |
| - insight::format_bf(bf, name="BF10", ...)) |
77 |
| - text |
| 82 | + other_text <- ifelse(bf < 1, |
| 83 | + insight::format_bf(1 / bf, name = "BF01", ...), |
| 84 | + insight::format_bf(bf, name = "BF10", ...) |
| 85 | + ) |
| 86 | + other_text |
78 | 87 | }
|
79 |
| - |
|
0 commit comments