grim_map: GRIM-test many cases at once

grim_mapR Documentation

GRIM-test many cases at once

Description

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.

Usage

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
)

Arguments

data

Data frame with columns x and n, and optionally items_averaged, data_type, and digits_x. Any other columns are returned alongside the results.

digits_x

Integer. The number of decimal places in x, including trailing zeros. There is no default, since a numeric value does not keep them (1.40 is 1.4). Either a single number for the whole column or one number per row of data. If left out, it is taken from a digits_x column of data.

x, n

Optionally, the names of the columns in data that contain these values, if they differ from the defaults.

...

These dots must be empty. Every argument after them must be named in full.

items_averaged

Integer. As in grim(): the number of items averaged into each score, not the number of scale points. Give it as an argument or as a column of data; there is no default. It is returned as a column.

data_type

String. As in grim(): "integer" or "continuous". Like items_averaged, give it as an argument or as a column of data; there is no default. It is returned as a column.

x_meaning

String. What the x values are: "mean" (the default) or "percentage". Percentages are divided by 100 and tested with two more decimal places. It applies to the whole call, so test a table that mixes means and percentages in parts, as in the examples of grim_map(). The parts record different settings, so they can't be combined with dplyr::bind_rows(). See Defaults in grim().

rounding, threshold, symmetric

Passed on to grim(), whose section Defaults explains the defaults.

show_rec

Logical. If TRUE, the reconstructed numbers are returned as columns; see Reconstructed numbers in grim_map(). Default is FALSE.

Value

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().

Reconstructed numbers

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.

Summaries with audit()

audit() on grim_map() output returns a tibble with one row and these columns:

  1. all_cases: total number of value sets.

  2. testable_cases: number of value sets with a positive exp_incon.

  3. incon_cases: number of GRIM-inconsistent value sets.

  4. emp_incon: proportion of GRIM-inconsistent value sets.

  5. exp_incon: mean probability of GRIM inconsistency.

  6. ratio: ratio of emp_incon to exp_incon, both computed over the value sets that could be decided.

References

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

Examples

# 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"
  )

scrutiny documentation built on Nov. 11, 2026, 1:09 a.m.