debit_values: Achievable means and SDs of binary data

View source: R/debit-values.R

debit_valuesR Documentation

Achievable means and SDs of binary data

Description

[Experimental]

debit_values() returns every pair of a mean and an SD that n binary values (0 and 1) can have and that would be reported as x and sd. It is the counterpart of grim_values() and grimmer_values() for debit(), which is TRUE exactly if there is at least one such pair.

debit_closest() returns the single achievable pair whose SD is closest to sd, like grimmer_closest(). If x and sd are consistent, it is one of the pairs that debit_values() returns. Otherwise, it is closest among the pairs whose mean would be reported as x, or, if there are none, it is the pair whose mean grim_closest() returns.

Usage

debit_values(
  x,
  sd,
  n,
  digits_x,
  digits_sd,
  data_type,
  sd_meaning = c("sd_sample", "sd_pop", "sd_sample_or_pop", "se"),
  formula = c("exact", "mean_n"),
  rounding = "up_or_down",
  threshold = 5,
  symmetric = FALSE
)

debit_closest(
  x,
  sd,
  n,
  digits_x,
  digits_sd,
  data_type,
  sd_meaning = c("sd_sample", "sd_pop", "sd_sample_or_pop", "se"),
  formula = c("exact", "mean_n"),
  rounding = "up_or_down",
  threshold = 5,
  symmetric = FALSE
)

Arguments

x

Numeric. The reported mean of the binary data, between 0 and 1.

sd

Numeric. The reported standard deviation, between 0 and 1.

n

Integer. The reported sample size.

digits_x, digits_sd

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

data_type

String. "integer" if the values are 0 and 1, as in debit(). There is no default, so that every call states this assumption. "continuous" is an error: such data can have any value that would be reported as the one given, so there are none to list. Under NA, a value set is undecidable unless no data can have it.

sd_meaning

String. As in debit(), but "sd_sample_or_pop" is not allowed: the same data have a different SD under each premise, so call debit_values() once for each. Under "se", the sd column holds the standard error.

formula

String. As in debit(), but only "exact", the default, is allowed: "mean_n" takes the mean as anything that would be reported as x, so there are no values to list.

rounding

String. The rounding method assumed to have produced x and sd. Default is "up_or_down". See grim() for the others.

threshold, symmetric

The same as in grim().

Details

More than a million numbers of ones whose mean would be reported as x is an error, since they are listed before the SD narrows them down. That takes an n of more than about 10^(digits_x + 6).

In debit_closest(), pairs whose SDs are equally close go by the mean closer to x, then by the smaller number of ones.

Value

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, and sum the number of ones, k in the mean k / n. An inconsistent value set has no rows, and one that cannot be decided has one row of NA but for n, as in debit().

debit_closest() returns the same columns with exactly one row per value set: of NA but for n if a value is missing or the value set cannot be decided.

See Also

debit(), debit_map(), debit_plot_line(), and sd_binary_groups().

Examples

# A mean of 0.35 and an SD of 0.49 are consistent with 20 binary values,
# 7 of them ones:
debit_values(
  x = 0.35,
  sd = 0.49,
  n = 20,
  digits_x = 2,
  digits_sd = 2,
  data_type = "integer"
)

# None if the value set is inconsistent:
debit_values(
  x = 0.35,
  sd = 0.41,
  n = 20,
  digits_x = 2,
  digits_sd = 2,
  data_type = "integer"
)

# With few decimal places and a large sample, there can be several:
debit_values(
  x = 0.5,
  sd = 0.5,
  n = 300,
  digits_x = 1,
  digits_sd = 1,
  data_type = "integer"
)

# The closest pair to an inconsistent one:
debit_closest(
  x = 0.35,
  sd = 0.41,
  n = 20,
  digits_x = 2,
  digits_sd = 2,
  data_type = "integer"
)

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