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,
  quiet = FALSE
)

Arguments

mean

The mean of the distribution

sd

The standard deviation 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.

sd_prec

The precision of the reported standard deviation, with the same requirements as m_prec. Specify it explicitly to preserve trailing zeroes.

n_items

Positive integer 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 TRUE, return the unrounded SDs within the tested rounding interval that satisfy the GRIMMER arithmetic conditions. Otherwise return a logical verdict.

return_list

If TRUE, return a list with logical passed and numeric values components, irrespective of return_values.

quiet

Suppress warnings.

Value

A logical scalar by default. With return_values = TRUE, a numeric vector of compatible unrounded SDs; an empty vector always means failure. With return_list = TRUE, a list with passed and values components. Candidate values satisfy the screening conditions and need not correspond to actual samples. Requests requiring more than one million candidates to be enumerated, or inputs beyond reliable integer arithmetic, stop with an informative error.

Details

GRIMMER compatibility is a necessary condition for a sample to exist, not proof that a sample exists. The integer, parity, and minimum-variance conditions on sums of squares can pass even when no sample produces the reported statistics. Optional scale bounds add a range check but do not make the test sufficient. For example, two integer observations on a scale from 0 to 4 cannot have mean 2 and SD 2.0, although these statistics pass GRIMMER.

Both endpoints of each reporting interval are accepted to accommodate different conventions for rounding ties. A reported SD of zero therefore also includes small positive SDs that round to zero.

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