Creates a data frame of possible combinations of n
(number of trials)
and p
(probabilities) that satisfy specified constraints on the mean, standard deviation,
and approximation conditions for normal or Poisson distributions.
The function applies the following rules:
If length(mean) == 1
and it is an integer, it specifies the number of digits
to which the mean should be rounded.
If mean = NA
(default), all mean values are allowed.
If length(mean) > 1
, only combinations where n * p
equals one of the specified means are retained.
The same logic applies to sd
for the standard deviation.
The norm
and pois
arguments can be logical, NA
, or a custom function of the form function(n, p)
.
They control which (n, p)
pairs are considered valid:
NA
allows all combinations.
A function returns TRUE
for valid combinations and FALSE
for invalid ones.
TRUE
enforces standard approximation rules:
norm
: n * p * (1 - p) > 9
(normal approximation condition)
pois
: n > 10 & p < 0.05
(Poisson approximation condition)
FALSE
excludes combinations that meet the approximation condition.
Note: The resulting data frame may be empty if no combinations meet all criteria.
binom_param(n, p, mean = NA, sd = NA, norm = NA, pois = NA, tol = 1e-06)
A data frame with columns n
, p
, mean
, and sd
representing valid parameter combinations.
integer vector of trial counts
numeric vector of probabilities
numeric or integer specifying required mean digits or specific mean values
numeric or integer specifying required standard deviation digits or specific sd values
logical, NA
, or function: restricts combinations to those valid for normal approximation
logical, NA
, or function: restricts combinations to those valid for Poisson approximation
numeric: tolerance for numerical comparisons (default: 1e-6
)
binom_param(1000:50000, (5:25)/100, mean = 0, sd = 0)
Run the code above in your browser using DataLab