Estimation of required sample size as given by Cundill & Alexander (2015).

n_binom(
  p0,
  effect,
  size = 1,
  alpha = 0.05,
  power = 0.9,
  q = 0.5,
  link = c("logit", "identity"),
  two_sided = TRUE
)

Arguments

p0

probability of success in group0

effect

Effect size, \(1 - (\mu_1 / \mu_0)\), where \(\mu_0\) is the mean in the control group (mean0) and \(\mu_1\) is the mean in the treatment group.

size

number of trials (greater than zero)

alpha

Type I error rate

power

1 - Type II error rate

q

Proportion of observations allocated to the control group

link

Link function to use. Currently implement: 'log' and 'identity'

two_sided

logical, if TRUE the sample size will be calculated for a two-sided test. Otherwise, the sample size will be calculated for a one-sided test.

Value

Returns an object of class "sample_size". It contains the following components:

N

the total sample size

n0

sample size in Group 0 (control group)

n1

sample size in Group 1 (treatment group)

two_sided

logical, TRUE, if the estimated sample size refers to a two-sided test

alpha

type I error rate used in sample size estimation

power

target power used in sample size estimation

effect

effect size used in sample size estimation

effect_type

short description of the type of effect size

comment

additional comment, if there is any

call

the matched call.

References

Cundill, B., & Alexander, N. D. E. (2015). Sample size calculations for skewed distributions. BMC Medical Research Methodology, 15(1), 1–9. https://doi.org/10.1186/s12874-015-0023-0

Examples

n_binom(p0 = 0.5, effect = 0.3)
#> Estimated sample size for group difference.
#> Generalized Regression, Binomial Distribution, link: logit 
#> 
#> N (total)		 1342.75 
#> n0 (Group 0)		 671.38 
#> n1 (Group 1)		 671.38 
#> 
#> Effect size		 0.3 
#> Effect type		 1 - Odds Ratio 
#> Type I error		 0.05 
#> Target power		 0.9 
#> Two-sided		 TRUE 
#> 
#> Call: n_binom(p0 = 0.5, effect = 0.3)