| grim_map | R Documentation |
grim_map() applies grim() to every row of a data frame
with means (or percentages) and sample sizes.
Set x_meaning to "percentage" if x contains percentages, and
show_rec to TRUE to see the reconstructed values behind each result.
Call these functions on the output of grim_map():
audit() for summary statistics.
grim_plot_grid() to visualize the results.
explain_print() to explain each result in plain words.
grim_map(
data,
digits_x,
x = NULL,
n = NULL,
...,
items_averaged,
data_type,
x_meaning = c("mean", "percentage"),
rounding = "up_or_down",
threshold = 5,
symmetric = FALSE,
show_rec = FALSE
)
data |
Data frame with columns |
digits_x |
Integer. The number of decimal places in |
x, n |
Optionally, the names of the columns in |
... |
These dots must be empty. Every argument after them must be named in full. |
items_averaged |
Integer. As in |
data_type |
String. As in |
x_meaning |
String. What the |
rounding, threshold, symmetric |
Passed on to |
show_rec |
Logical. If |
A tibble with these columns:
x, n: the inputs.
items_averaged: the number of items averaged into each score.
data_type: the kind of data, as given.
digits_x: the number of decimal places in x, as given.
consistency: GRIM consistency of x, n, and items_averaged. NA for
a case that cannot be decided, such as one with a missing value.
exp_incon: the probability of GRIM inconsistency; see
grim_exp_incon().
Any other columns from data.
The tibble has the class scrutiny_grim_map, which is recognized by
audit() and grim_plot_grid().
With show_rec = TRUE, the output has these
further columns, the same ones for every rounding method:
rec_sum: the product of x and n (times items_averaged), i.e., the
sum total implied by the reported mean. It is generally not a whole number.
sum_lower, sum_upper: the least and the greatest whole-number sum total
that would have been reported as x. A value set is consistent exactly if
sum_lower is not greater than sum_upper. If it is inconsistent, the two
are the whole numbers on either side of rec_sum, so their gap is always 1
and does not measure how far off the reported values are.
rec_x_upper, rec_x_lower: the two achievable means closest to x,
i.e., rec_sum rounded up and down, divided by n (times
items_averaged).
With x_meaning = "percentage", rec_sum is x / 100 times n (times
items_averaged), and rec_x_upper and rec_x_lower are percentages like
x.
audit()audit() on grim_map() output
returns a tibble with one row and these columns:
all_cases: total number of value sets.
testable_cases: number of value sets with a positive exp_incon.
incon_cases: number of GRIM-inconsistent value sets.
emp_incon: proportion of GRIM-inconsistent value sets.
exp_incon: mean probability of GRIM inconsistency.
ratio: ratio of emp_incon to exp_incon, both computed over the
value sets that could be decided.
Brown, N. J. L., & Heathers, J. A. J. (2017). The GRIM Test: A Simple Technique Detects Numerous Anomalies in the Reporting of Results in Psychology. Social Psychological and Personality Science, 8(4), 363–369. https://journals.sagepub.com/doi/10.1177/1948550616673876
# Use `grim_map()` on data like these:
pigs1
# The `consistency` column shows whether the
# values to its left are GRIM-consistent:
pigs1 |>
grim_map(digits_x = 2, items_averaged = 1, data_type = "integer")
# Show the reconstructed numbers:
pigs1 |>
grim_map(
digits_x = 2,
items_averaged = 1,
data_type = "integer",
show_rec = TRUE
)
# Get summaries with `audit()`:
pigs1 |>
grim_map(digits_x = 2, items_averaged = 1, data_type = "integer") |>
audit()
# Explain the results in plain words:
pigs1 |>
grim_map(digits_x = 2, items_averaged = 1, data_type = "integer") |>
explain_print(1:2)
# A table of means and percentages, tested in parts:
df <- tibble::tibble(
x = c(5.19, 71),
n = c(32, 43),
is_percent = c(FALSE, TRUE)
)
df |>
dplyr::filter(!is_percent) |>
grim_map(digits_x = 2, items_averaged = 1, data_type = "integer")
df |>
dplyr::filter(is_percent) |>
grim_map(
digits_x = 0,
items_averaged = 1,
data_type = "integer",
x_meaning = "percentage"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.