This function tests whether a given mean (with a specific precision) can result from a sample of a given size based on integer responses to one or more items. The test is based on Brown & Heathers (2017).

GRIM_test(
  mean,
  n_obs,
  m_prec = NULL,
  n_items = 1,
  return_values = FALSE,
  return_list = FALSE,
  quiet = FALSE
)

Arguments

mean

The mean of the distribution

n_obs

The number of observations (sample size), an integer of at least two for reconstruction.

m_prec

The precision of the reported mean, as a nonnegative integer number of decimal places (at most 308), consistent with the supplied value. Inferred from the numeric value if omitted; specify it explicitly when the reported mean ends in zero.

n_items

Positive integer number of items in scale, if distribution represents scale averages. Defaults to 1, which represents any single-item measure.

return_values

A logical value. ignored if return_list = TRUE. If FALSE (the default), the function returns a simple TRUE or FALSE. If TRUE, it returns a numeric vector of all possible means that are consistent with the parameters. If the test fails when return_values = TRUE, a warning is issued and the closest consistent mean is returned. If there are two equally close means, both are returned.

return_list

A logical value. If FALSE (the default), the function's return type is determined by return_values. If TRUE, the function instead returns a list containing two elements: a logical passed flag and a numeric vector values containing the relevant means.

quiet

Suppress warnings.

Value

The return type depends on the arguments. By default, a logical scalar (TRUE or FALSE). If return_values = TRUE, a numeric vector is returned. If return_list = TRUE, a list is returned.

Details

Logical-only requests compare interval endpoints without enumerating possible means. Value and list requests stop if more than one million candidates would need enumeration. Inputs beyond reliable integer arithmetic also stop with an informative error.

References

Brown NJ, Heathers JA (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.

Examples

# A sample of 28 integers cannot result in a mean of 5.19.
GRIM_test(mean = 5.19, n_obs = 28)
#> [1] FALSE

# To find the closest possible mean, set return_values to TRUE
GRIM_test(mean = 5.19, n_obs = 28, return_values = TRUE)
#> Warning: Mean 5.19 fails GRIM test - closest consistent value(s): 5.18
#> [1] 5.18

# To get a detailed list containing both the logical result and the values
GRIM_test(mean = 5.19, n_obs = 28, return_list = TRUE)
#> $passed
#> [1] FALSE
#> 
#> $values
#> [1] 5.18
#>