grimmer_explain: Explain a GRIMMER test step by step

View source: R/grimmer-explain.R

grimmer_explainR Documentation

Explain a GRIMMER test step by step

Description

[Experimental]

grimmer_explain() tests a single mean and SD like grimmer() does, but also lays out the calculation in plain words. It starts with the GRIM test of the mean, as in grim_explain(), and goes on to the sum of squares that each possible sum implies with the SD.

The text is built from the numbers that decide the test itself, so it always agrees with grimmer().

Usage

grimmer_explain(
  x,
  sd,
  n,
  digits_x,
  digits_sd,
  items_averaged,
  data_type,
  sd_meaning = c("sd_sample", "sd_pop", "sd_sample_or_pop", "se"),
  rounding = "up_or_down",
  threshold = 5,
  symmetric = FALSE
)

Arguments

x

Numeric. The reported mean.

sd

Numeric. The reported standard deviation.

n

Integer. The reported sample size.

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

digits_sd

Integer. The number of decimal places in sd, including trailing zeros. There is no default, since a numeric value does not keep them (1.40 is 1.4).

items_averaged

Integer. As in grim(), for x and sd.

data_type

String. As in grim(): "integer" or "continuous". No default. Continuous data can have any mean and any SD of 0 or more, but a single value only an SD of 0.

sd_meaning

String. What sd really is. "sd_sample" (the default) is the sample SD, which divides by n - 1; "sd_pop" is the population SD, which divides by n; "sd_sample_or_pop" accepts either; "se" is the standard error of the mean, the sample SD divided by sqrt(n), reported as if it were an SD. See Defaults and SD meaning in grimmer().

rounding

String. The rounding method assumed to have produced x. Default is "up_or_down", which accepts either direction; see Defaults in grim(). The others are "up_from_or_down_from", "ceiling_or_floor", "up", "down", "even", "up_from", "down_from", "ceiling", "floor", "trunc", "anti_trunc", "ties_up", "ties_down", "ties_away", "ties_zero", and "ties_even". See vignette("rounding-options", package = "roundwork").

threshold

Numeric. For rounding = "up_from", "down_from", or "up_from_or_down_from", the point within a step at which rounding switches direction, in tenths of a step. Default is 5. Ignored otherwise.

symmetric

Logical. If TRUE, negative numbers are rounded like their absolute values (-2.5 like 2.5) under "up", "down", and the "*_from" methods. Default is FALSE. Must not be TRUE with a "ties_*" rounding method, which already fixes the direction; see roundwork::reround().

Value

An object of class scrutiny_explain: a list with the result as consistency (TRUE, FALSE, or NA), the explanation's paragraphs, and the test and its inputs. It prints as the explanation.

Examples

grimmer_explain(
  x = 5.23,
  sd = 2.55,
  n = 35,
  digits_x = 2,
  digits_sd = 2,
  items_averaged = 1,
  data_type = "integer"
)

grimmer_explain(
  x = 5.23,
  sd = 2.55,
  n = 31,
  digits_x = 2,
  digits_sd = 2,
  items_averaged = 1,
  data_type = "integer"
)

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