|
59 | 59 | #' @examples
|
60 | 60 | #' y <- example_y_data()
|
61 | 61 | #' yrep <- example_yrep_draws()
|
62 |
| -#' ppc_stat(y, yrep) |
| 62 | +#' ppc_stat(y, yrep, stat = "median") |
63 | 63 | #' ppc_stat(y, yrep, stat = "sd") + legend_none()
|
64 | 64 | #'
|
65 | 65 | #' # use your own function for the 'stat' argument
|
|
74 | 74 | #' # plots by group
|
75 | 75 | #' color_scheme_set("teal")
|
76 | 76 | #' group <- example_group_data()
|
77 |
| -#' ppc_stat_grouped(y, yrep, group) |
78 |
| -#' ppc_stat_grouped(y, yrep, group) + yaxis_text() |
| 77 | +#' ppc_stat_grouped(y, yrep, group, stat = "median") |
| 78 | +#' ppc_stat_grouped(y, yrep, group, stat = "mad") + yaxis_text() |
79 | 79 | #'
|
80 | 80 | #' # force y-axes to have same scales, allow x axis to vary
|
81 | 81 | #' ppc_stat_grouped(y, yrep, group, facet_args = list(scales = "free_x")) + yaxis_text()
|
@@ -111,6 +111,7 @@ ppc_stat <-
|
111 | 111 | breaks = NULL,
|
112 | 112 | freq = TRUE) {
|
113 | 113 | stopifnot(length(stat) == 1)
|
| 114 | + message_if_using_mean(stat) |
114 | 115 | dots <- list(...)
|
115 | 116 | if (!from_grouped(dots)) {
|
116 | 117 | check_ignored_arguments(...)
|
@@ -194,6 +195,7 @@ ppc_stat_freqpoly <-
|
194 | 195 | bins = NULL,
|
195 | 196 | freq = TRUE) {
|
196 | 197 | stopifnot(length(stat) == 1)
|
| 198 | + message_if_using_mean(stat) |
197 | 199 | dots <- list(...)
|
198 | 200 | if (!from_grouped(dots)) {
|
199 | 201 | check_ignored_arguments(...)
|
@@ -275,6 +277,8 @@ ppc_stat_2d <- function(y,
|
275 | 277 | if (length(stat) != 2) {
|
276 | 278 | abort("For ppc_stat_2d the 'stat' argument must have length 2.")
|
277 | 279 | }
|
| 280 | + message_if_using_mean(stat[1]) |
| 281 | + message_if_using_mean(stat[2]) |
278 | 282 |
|
279 | 283 | if (is.character(stat)) {
|
280 | 284 | lgnd_title <- bquote(italic(T) == (list(.(stat[1]), .(stat[2]))))
|
@@ -410,3 +414,12 @@ stat_2d_segment_data <- function(data) {
|
410 | 414 | Ty_label <- function() expression(italic(T(italic(y))))
|
411 | 415 | Tyrep_label <- function() expression(italic(T)(italic(y)[rep]))
|
412 | 416 |
|
| 417 | + |
| 418 | +message_if_using_mean <- function(stat) { |
| 419 | + if (is.character(stat) && stat == "mean") { |
| 420 | + message( |
| 421 | + "Note: in most cases the default test statistic 'mean' is ", |
| 422 | + "too weak to detect anything of interest." |
| 423 | + ) |
| 424 | + } |
| 425 | +} |
0 commit comments