This function tests whether a given standard deviation (with a specific precision) can result from a sample of a given size based on integer responses to one or more items. The test was first proposed by Anaya (2016); here, the algorithm developed by Allard (2018) is used, extended by Aurélien Allard to support multi-item scales.

GRIMMER_test(
  mean,
  sd,
  n_obs,
  m_prec = NULL,
  sd_prec = NULL,
  n_items = 1,
  min_val = NULL,
  max_val = NULL,
  return_values = FALSE,
  return_list = FALSE
)

Arguments

mean

The mean of the distribution

sd

The standard deviation of the distribution

n_obs

The number of observations (sample size)

m_prec

The precision of the mean, as number of digits after the decimal point. If not provided, taken based on the significant digits of mean - so only needed if reported mean ends in 0

sd_prec

The precision of the standard deviation, again only needed if reported standard deviation ends in 0.

n_items

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

min_val

(Optional) Scale minimum. If provided alongside max_val, the function checks whether the SD is consistent with that range.

max_val

(Optional) Scale maximum.

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 unrounded standard deviations that are consistent - unless the precision/sample size ratio allows for all standard deviations within the possible range to be GRIMMER-consistent. In that case, a message is shown and an empty numeric vector is 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 a logical passed flag and a numeric values vector.

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. An inconsistent result will yield FALSE, an empty numeric vector, or a list with passed = FALSE.

References

Anaya J (2016). “The GRIMMER test: A method for testing the validity of reported measures of variability.” PeerJ Preprints, 4, e2400v1. Allard A (2018). “Analytic-GRIMMER: A New Way of Testing the Possibility of Standard Deviations.” https://aurelienallard.netlify.app/post/anaytic-grimmer-possibility-standard-deviations/. Accessed: 2025-07-09.

Examples

# A sample of 18 integers with mean 3.44 cannot have an SD of 2.47.
GRIMMER_test(mean = 3.44, sd = 2.47, n_obs = 18)
#> [1] FALSE

# Get a detailed list containing both the logical result and any possible values
GRIMMER_test(mean = 3.5, sd = 1.21, n_obs = 10, return_list = TRUE)
#> $passed
#> [1] FALSE
#> 
#> $values
#> numeric(0)
#>