View source: R/grimmer-values.R
| grimmer_values | R Documentation |
grimmer_values() returns every pair of a mean and an SD that a sample of
n integers can have and that would be reported as x and sd. It
is the counterpart of grim_values() for grimmer(), which is TRUE
exactly if there is at least one such pair.
grimmer_closest() returns the single achievable pair whose SD is
closest to sd, like grim_closest() for means. If x and sd are
consistent, it is one of the pairs that grimmer_values() returns.
Otherwise, it is closest among the pairs whose mean would be reported as
x, or, if there are none, whose mean is the one grim_closest()
returns.
Each pair comes with the whole-number sum and sum of squares behind it. Statistics computed from several groups, such as a t-value, can be compared exactly through these integers.
grimmer_values(
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
)
grimmer_closest(
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
)
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 |
digits_sd |
Integer. The number of decimal places in |
items_averaged |
Integer. As in |
data_type |
String. |
sd_meaning |
String. As in |
rounding |
String. The rounding method assumed to have produced |
threshold |
Numeric. For |
symmetric |
Logical. If |
The sums are the whole numbers that grim_values() divides by
n * items_averaged. For each, the sums of squares are the whole numbers
within the rounding bounds of sd that n integers with that sum can
have. With items_averaged > 1, the integers are the respondents'
totals across the items, so the sums are those of the totals.
The number of pairs grows with n, items_averaged, and sd, and
shrinks with digits_x and digits_sd. More than a million pairs for one
value set is an error, since the output has one row for each. So is a sum
of squares of 2^53 or more, about 9e15, which a double can't hold exactly;
grimmer() tests such value sets all the same. grimmer_closest()
stops at 2^48, about 3e14, beyond which it can miss the closest pair.
With n from 2 to 4, both stop at 2^40, about 1.1e12, as grimmer()
does; grimmer_closest() stops there even if x fails GRIM.
Under rounding = "even", the pairs include ties that base::round()
may round away from x or sd, as in grim_values().
In grimmer_closest(), pairs whose SDs are equally close go by the mean
closer to x, then by the smaller sum, then by the smaller SD. A negative
sd is closest to the least SD there is. The number of pairs doesn't
matter there, but that of the sums does: for a consistent value set, it
tries one sum per remainder modulo n, and more than 100,000 of them is
an error. That takes an n of more than about 10^(digits_x + 5).
A tibble with one row per achievable pair. case is the index of the
value set, as in grim_values(). x and sd are the achievable values,
n the reported sample size, items_averaged as given, and sum and
sum_squares the whole numbers behind them. An inconsistent value set has
no rows, and one that cannot be decided has one row of NA but for n and
items_averaged, as in grimmer().
grimmer_closest() returns the same columns with exactly one row per
value set: of NA but for n and items_averaged if a value is missing
or the value set cannot be decided.
grimmer(), grimmer_map(), grim_values(), and
grimmer_plot_line().
# A mean of 5.23 and an SD of 2.55 are consistent with a sample size of 31,
# and there is exactly one way to get there:
grimmer_values(
x = 5.23,
sd = 2.55,
n = 31,
digits_x = 2,
digits_sd = 2,
items_averaged = 1,
data_type = "integer"
)
# With one decimal place, several pairs round to the same values:
grimmer_values(
x = 5.3,
sd = 0.7,
n = 30,
digits_x = 1,
digits_sd = 1,
items_averaged = 1,
data_type = "integer"
)
# None at all if the value set is inconsistent:
grimmer_values(
x = 5.23,
sd = 2.55,
n = 35,
digits_x = 2,
digits_sd = 2,
items_averaged = 1,
data_type = "integer"
)
# ...but there is a pair close to it:
grimmer_closest(
x = 5.23,
sd = 2.55,
n = 35,
digits_x = 2,
digits_sd = 2,
items_averaged = 1,
data_type = "integer"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.