| Title: | Sample Size Planning with Methods Text and References |
|---|---|
| Description: | Sample size calculations for the study designs most used in health and social research: estimating a proportion or mean (with finite-population correction and design effect), comparing two groups (proportions, means, paired data), case-control and cohort studies, diagnostic accuracy, Buderer (1996) <doi:10.1111/j.1553-2712.1996.tb03538.x>, correlation and regression, one-way and repeated-measures analysis of variance, logistic regression, Hsieh, Bloch and Larsen (1998) <doi:10.1002/(SICI)1097-0258(19980730)17:14%3C1623::AID-SIM871%3E3.0.CO;2-S>, survival, Schoenfeld (1983) <doi:10.2307/2531021>, incidence rates, non-inferiority and equivalence trials, longitudinal designs, Diggle, Heagerty, Liang and Zeger (2002, ISBN:9780198524847), and cluster-randomised trials with unequal cluster sizes, Eldridge, Ashby and Kerry (2006) <doi:10.1093/ije/dyl129>, with adjustment for several primary outcomes and for nonresponse. Each result can be turned into a ready-to-use methods paragraph that states every assumption, the target before and after nonresponse and the adjustments made, with the formula and references. The same calculations power the sample size calculator at <https://researchite.com/sample-size>. |
| Authors: | Tesfahun Mulatu [aut, cre, cph] |
| Maintainer: | Tesfahun Mulatu <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-11-29 19:42:53 UTC |
| Source: | https://github.com/cran/researchite |
, for clusters of average size
whose sizes vary with coefficient of variation ; with equal clusters
() this is Kish's (Eldridge, Ashby & Kerry 2006).
design_effect(cluster_size, icc, cv = 0)design_effect(cluster_size, icc, cv = 0)
cluster_size |
Average number of people per cluster. |
icc |
Intracluster correlation coefficient. |
cv |
Coefficient of variation of cluster sizes (0 for equal sizes). |
The design effect, a single number.
Kish L (1965). Survey Sampling. New York: Wiley.
Eldridge SM, Ashby D, Kerry S (2006). Sample size for cluster randomized trials: effect of coefficient of variation of cluster size and analysis method. International Journal of Epidemiology 35(5):1292-1300.
design_effect(cluster_size = 20, icc = 0.05) ss_proportion(p = 0.3, precision = 0.05, deff = design_effect(20, 0.05))design_effect(cluster_size = 20, icc = 0.05) ss_proportion(p = 0.3, precision = 0.05, deff = design_effect(20, 0.05))
The formula used for a sample size calculation
formula_text(x)formula_text(x)
x |
An object of class 'studysize'. |
A single string.
formula_text(ss_two_means(delta = 5, sd = 10))formula_text(ss_two_means(delta = 5, sd = 10))
Writes the sample size paragraph for a protocol, thesis or paper: what the calculation was for, every assumption, the result before and after nonresponse, and the adjustments made, followed (optionally) by the formula and the references. The wording is rule-based, so the same calculation always gives the same text, and every number comes from the calculation itself. Edit it to fit your study; the assumptions still need justifying from earlier studies or pilot data.
methods_text(x, formula = FALSE, references = TRUE, software = TRUE)methods_text(x, formula = FALSE, references = TRUE, software = TRUE)
x |
An object of class 'studysize', from one of the 'ss_*()' functions. |
formula |
Add the formula used. |
references |
Add the references. |
software |
Mention this package (and cite it in the references). |
A single string, with paragraphs separated by blank lines. Print it with [cat()] or [writeLines()].
x <- ss_proportion(p = 0.5, precision = 0.05, deff = 1.5, nonresponse = 0.1) cat(methods_text(x)) cat(methods_text(ss_case_control(p0 = 0.2, or = 2, ratio = 2, nonresponse = 0.05)))x <- ss_proportion(p = 0.5, precision = 0.05, deff = 1.5, nonresponse = 0.1) cat(methods_text(x)) cat(methods_text(ss_case_control(p0 = 0.2, or = 2, ratio = 2, nonresponse = 0.05)))
The methodological sources for the calculation and for each adjustment it uses (design effect, nonresponse, finite population, several outcomes).
references(x, software = TRUE)references(x, software = TRUE)
x |
An object of class 'studysize'. |
software |
Add the citation for this package. |
A character vector of references.
references(ss_proportion(p = 0.3, precision = 0.05, deff = 2))references(ss_proportion(p = 0.3, precision = 0.05, deff = 2))
Analysis of covariance of the mean of follow-up measurements,
adjusted for one baseline measurement, with correlation between
all measurements (Frison & Pocock 1992):
.
With one follow-up this is the familiar factor (Borm et al. 2007).
ss_ancova( delta, sd, rho, followups = 1, ratio = 1, sig.level = 0.05, power = 0.8, nonresponse = 0, method = c("z", "t"), outcomes = 1, rule = c("any", "all") )ss_ancova( delta, sd, rho, followups = 1, ratio = 1, sig.level = 0.05, power = 0.8, nonresponse = 0, method = c("z", "t"), outcomes = 1, rule = c("any", "all") )
delta |
Difference between groups at follow-up to detect. |
sd |
Standard deviation of one measurement. |
rho |
Correlation between baseline and follow-up (and between follow-ups). |
followups |
Number of follow-up measurements (1 to 50). |
ratio |
Allocation ratio, group 2 : group 1. |
sig.level |
Two-sided significance level. |
power |
Power. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
method |
'"z"', or '"t"' (exact t-test power; 'summary = "mean"' only). |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'.
Frison L, Pocock SJ (1992). Repeated measures in clinical trials: analysis using mean summary statistics and its implications for design. Statistics in Medicine 11(13):1685-1704.
Borm GF, Fransen J, Lemmens WAJG (2007). A simple sample size formula for analysis of covariance in randomized clinical trials. Journal of Clinical Epidemiology 60(12):1234-1238.
ss_ancova(delta = 5, sd = 10, rho = 0.6)ss_ancova(delta = 5, sd = 10, rho = 0.6)
The smallest equal group size whose power, from the noncentral F
distribution with noncentrality , reaches the target
(Cohen 1988); is Cohen's effect size.
ss_anova( f, groups, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )ss_anova( f, groups, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )
f |
Cohen's f. |
groups |
Number of groups (2 or more). |
sig.level |
Two-sided significance level. |
power |
Power. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'.
Cohen J (1988). Statistical Power Analysis for the Behavioral Sciences, 2nd ed. Hillsdale: Lawrence Erlbaum.
ss_anova(f = 0.25, groups = 3)ss_anova(f = 0.25, groups = 3)
The exposure among cases implied by the odds ratio,
, compared with the exposure among
controls by the two-proportions formula of
[ss_two_proportions()] (Kelsey et al. 1996).
ss_case_control( p0, or, ratio = 1, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )ss_case_control( p0, or, ratio = 1, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )
p0 |
Expected proportion exposed among controls. |
or |
Odds ratio to detect. |
ratio |
Controls per case. |
sig.level |
Two-sided significance level. |
power |
Power. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'.
Kelsey JL, Whittemore AS, Evans AS, Thompson WD (1996). Methods in Observational Epidemiology, 2nd ed. New York: Oxford University Press.
Schlesselman JJ (1982). Case-Control Studies: Design, Conduct, Analysis. New York: Oxford University Press.
ss_case_control(p0 = 0.2, or = 2, ratio = 2)ss_case_control(p0 = 0.2, or = 2, ratio = 2)
Clusters per arm , with the individually
randomised size per arm and from [design_effect()]. The critical
values use Student's t on degrees of freedom: is the smallest
number of clusters whose own t values need no more, as recommended when clusters are few (Hayes & Moulton
2017).
ss_cluster_means( delta, sd, cluster_size, icc, cv = 0, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") ) ss_cluster_proportions( p1, p2, cluster_size, icc, cv = 0, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )ss_cluster_means( delta, sd, cluster_size, icc, cv = 0, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") ) ss_cluster_proportions( p1, p2, cluster_size, icc, cv = 0, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )
delta |
Difference in means between arms to detect. |
sd |
Standard deviation of the outcome (individual level). |
cluster_size |
Average number of people per cluster. |
icc |
Intracluster correlation coefficient. |
cv |
Coefficient of variation of cluster sizes (0 for equal sizes). |
sig.level |
Two-sided significance level. |
power |
Power. |
nonresponse |
Expected proportion lost within each cluster. |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
p1, p2
|
Expected proportions in the intervention and control arms. |
An object of class 'studysize'; 'extra$clusters' holds the clusters per arm, and 'extra$deff' the design effect.
Hayes RJ, Moulton LH (2017). Cluster Randomised Trials, 2nd ed. Boca Raton: Chapman & Hall/CRC.
Eldridge SM, Ashby D, Kerry S (2006). Sample size for cluster randomized trials: effect of coefficient of variation of cluster size and analysis method. International Journal of Epidemiology 35(5):1292-1300.
Donner A, Klar N (2000). Design and Analysis of Cluster Randomization Trials in Health Research. London: Arnold.
ss_cluster_means(delta = 0.3, sd = 1, cluster_size = 20, icc = 0.05) ss_cluster_proportions(p1 = 0.4, p2 = 0.25, cluster_size = 30, icc = 0.02, cv = 0.4)ss_cluster_means(delta = 0.3, sd = 1, cluster_size = 20, icc = 0.05) ss_cluster_proportions(p1 = 0.4, p2 = 0.25, cluster_size = 30, icc = 0.02, cv = 0.4)
The two-proportions formula of [ss_two_proportions()] applied to the risk in the exposed (group 1) and unexposed (group 2) groups.
ss_cohort( p1, p2, ratio = 1, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )ss_cohort( p1, p2, ratio = 1, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )
p1 |
Expected risk among the exposed. |
p2 |
Expected risk among the unexposed. |
ratio |
Unexposed per exposed participant. |
sig.level |
Two-sided significance level. |
power |
Power. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'.
Kelsey JL, Whittemore AS, Evans AS, Thompson WD (1996). Methods in Observational Epidemiology, 2nd ed. New York: Oxford University Press.
ss_cohort(p1 = 0.15, p2 = 0.08, ratio = 2)ss_cohort(p1 = 0.15, p2 = 0.08, ratio = 2)
Fisher's z approximation, ,
where is the number of other predictors controlled for (
for a plain Pearson correlation; Cohen 1988).
ss_correlation( r, covariates = 0, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )ss_correlation( r, covariates = 0, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )
r |
Expected correlation (or partial correlation when 'covariates > 0'), between -1 and 1 and not 0. |
covariates |
Number of other predictors controlled for. |
sig.level |
Two-sided significance level. |
power |
Power. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'.
Cohen J (1988). Statistical Power Analysis for the Behavioral Sciences, 2nd ed. Hillsdale: Lawrence Erlbaum.
ss_correlation(r = 0.3) ss_correlation(r = 0.2, covariates = 4)ss_correlation(r = 0.3) ss_correlation(r = 0.2, covariates = 4)
The person-time needed to compare two Poisson rates (Breslow & Day 1987),
,
converted to participants by the average follow-up.
ss_incidence_rates( rate1, rate2, followup, ratio = 1, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )ss_incidence_rates( rate1, rate2, followup, ratio = 1, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )
rate1, rate2
|
Incidence rates (events per unit of person-time). |
followup |
Average follow-up per participant, in the same time unit. |
ratio |
Person-time ratio, group 2 : group 1. |
sig.level |
Two-sided significance level. |
power |
Power. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'.
Breslow NE, Day NE (1987). Statistical Methods in Cancer Research, Vol. II: The Design and Analysis of Cohort Studies. Lyon: IARC.
ss_incidence_rates(rate1 = 0.05, rate2 = 0.03, followup = 2)ss_incidence_rates(rate1 = 0.05, rate2 = 0.03, followup = 2)
The outcome probability at the predictor's other level implied by the
odds ratio, compared by the two-proportions formula and inflated by the
variance-inflation factor for the other covariates
(Hsieh, Bloch & Larsen 1998).
ss_logistic( p0, or, ratio = 1, r2 = 0, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )ss_logistic( p0, or, ratio = 1, r2 = 0, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )
p0 |
Outcome probability at the reference level of the predictor. |
or |
Odds ratio to detect. |
ratio |
Allocation, predictor = 1 : predictor = 0. |
r2 |
Proportion of the predictor's variance explained by the other covariates (0 when there are none). |
sig.level |
Two-sided significance level. |
power |
Power. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'.
Hsieh FY, Bloch DA, Larsen MD (1998). A simple method of sample size calculation for linear and logistic regression. Statistics in Medicine 17(14):1623-1634.
ss_logistic(p0 = 0.2, or = 1.8, r2 = 0.1)ss_logistic(p0 = 0.2, or = 1.8, r2 = 0.1)
Schoenfeld's (1983) number of events,
with
, converted to participants with the expected
probability of an event in each group by the end of the study.
ss_logrank( hr, p1, p2, ratio = 1, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )ss_logrank( hr, p1, p2, ratio = 1, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )
hr |
Hazard ratio to detect. |
p1, p2
|
Expected probability of an event by the end of the study in group 1 and group 2. |
ratio |
Allocation ratio, group 2 : group 1. |
sig.level |
Two-sided significance level. |
power |
Power. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'; 'extra$events' holds the events needed.
Schoenfeld DA (1983). Sample-size formula for the proportional-hazards regression model. Biometrics 39(2):499-503.
ss_logrank(hr = 0.7, p1 = 0.3, p2 = 0.4)ss_logrank(hr = 0.7, p1 = 0.3, p2 = 0.4)
Connor's (1987) formula for the number of matched pairs:
,
with and .
ss_mcnemar( p01, p10, sig.level = 0.05, power = 0.8, deff = 1, nonresponse = 0, outcomes = 1, rule = c("any", "all") )ss_mcnemar( p01, p10, sig.level = 0.05, power = 0.8, deff = 1, nonresponse = 0, outcomes = 1, rule = c("any", "all") )
p01, p10
|
Expected proportions of the two kinds of discordant pairs (changing from 0 to 1, and from 1 to 0). |
sig.level |
Two-sided significance level. |
power |
Power. |
deff |
Design effect. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'; the unit is pairs.
Connor RJ (1987). Sample size for testing differences in proportions for the paired-sample design. Biometrics 43(1):207-211.
ss_mcnemar(p01 = 0.25, p10 = 0.10)ss_mcnemar(p01 = 0.25, p10 = 0.10)
The number of participants needed to estimate a mean to within a given
precision: , with optional finite-population
correction and design effect, then inflated for nonresponse. 'method = "t"'
gives the smallest for which Student's on
degrees of freedom reaches the precision.
ss_mean( sd, precision, conf.level = 0.95, population = NULL, deff = 1, nonresponse = 0, method = c("z", "t") )ss_mean( sd, precision, conf.level = 0.95, population = NULL, deff = 1, nonresponse = 0, method = c("z", "t") )
sd |
Expected standard deviation. |
precision |
Precision |
conf.level |
Confidence level (two-sided). |
population |
Size of the population sampled, for the finite-population correction; 'NULL' (the default) for no correction. |
deff |
Design effect (1 for simple random sampling; often 1.5 to 2 for multistage cluster samples). |
nonresponse |
Expected proportion of nonresponse or loss, from 0 up to 1. |
method |
‘"z"' (normal) or '"t"' (Student’s t). |
An object of class 'studysize'.
Cochran WG (1977). Sampling Techniques, 3rd ed. New York: Wiley.
ss_mean(sd = 12, precision = 2) ss_mean(sd = 12, precision = 4, method = "t")ss_mean(sd = 12, precision = 2) ss_mean(sd = 12, precision = 4, method = "t")
Means: , assuming no
true difference. Proportions: ,
with for non-inferiority or
for equivalence. is one-sided; for
equivalence (two one-sided tests) becomes
(Julious 2004; Chow, Shao & Wang 2008).
ss_noninferiority_means( margin, sd, ratio = 1, sig.level = 0.025, power = 0.8, deff = 1, nonresponse = 0, type = c("noninferiority", "equivalence") ) ss_noninferiority_proportions( p1, p2, margin, ratio = 1, sig.level = 0.025, power = 0.8, deff = 1, nonresponse = 0, type = c("noninferiority", "equivalence") )ss_noninferiority_means( margin, sd, ratio = 1, sig.level = 0.025, power = 0.8, deff = 1, nonresponse = 0, type = c("noninferiority", "equivalence") ) ss_noninferiority_proportions( p1, p2, margin, ratio = 1, sig.level = 0.025, power = 0.8, deff = 1, nonresponse = 0, type = c("noninferiority", "equivalence") )
margin |
The non-inferiority or equivalence margin (for proportions, between 0 and 1). |
sd |
Common standard deviation. |
ratio |
Allocation ratio, group 2 : group 1. |
sig.level |
One-sided significance level (0.025 corresponds to a two-sided 95% confidence interval). |
power |
Power. |
deff |
Design effect. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
type |
'"noninferiority"' or '"equivalence"'. |
p1, p2
|
Expected proportions with the new (test) and reference treatment. |
An object of class 'studysize'.
Julious SA (2004). Sample sizes for clinical trials with Normal data. Statistics in Medicine 23(12):1921-1986.
Chow SC, Shao J, Wang H (2008). Sample Size Calculations in Clinical Research, 2nd ed. Boca Raton: Chapman & Hall/CRC.
ss_noninferiority_means(margin = 3, sd = 10) ss_noninferiority_proportions(p1 = 0.85, p2 = 0.85, margin = 0.1)ss_noninferiority_means(margin = 3, sd = 10) ss_noninferiority_proportions(p1 = 0.85, p2 = 0.85, margin = 0.1)
, with the
difference from the reference value to detect. 'method = "t"' solves the exact
one-sample t-test power (noncentral t) for , as [stats::power.t.test()].
ss_one_mean( delta, sd, sig.level = 0.05, power = 0.8, deff = 1, nonresponse = 0, method = c("z", "t"), outcomes = 1, rule = c("any", "all") )ss_one_mean( delta, sd, sig.level = 0.05, power = 0.8, deff = 1, nonresponse = 0, method = c("z", "t"), outcomes = 1, rule = c("any", "all") )
delta |
Difference from the reference value to detect. |
sd |
Common standard deviation. |
sig.level |
Two-sided significance level. |
power |
Power. |
deff |
Design effect. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
method |
'"z"' (normal approximation) or '"t"' (exact t-test power). |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'.
Chow SC, Shao J, Wang H (2008). Sample Size Calculations in Clinical Research, 2nd ed. Boca Raton: Chapman & Hall/CRC.
ss_one_mean(delta = 4, sd = 10)ss_one_mean(delta = 4, sd = 10)
(Fleiss, Levin & Paik 2003).
ss_one_proportion( p, p0, sig.level = 0.05, power = 0.8, deff = 1, nonresponse = 0, outcomes = 1, rule = c("any", "all") )ss_one_proportion( p, p0, sig.level = 0.05, power = 0.8, deff = 1, nonresponse = 0, outcomes = 1, rule = c("any", "all") )
p |
Expected (true) proportion. |
p0 |
Reference value. |
sig.level |
Two-sided significance level. |
power |
Power. |
deff |
Design effect. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'.
Fleiss JL, Levin B, Paik MC (2003). Statistical Methods for Rates and Proportions, 3rd ed. Hoboken: Wiley.
ss_one_proportion(p = 0.65, p0 = 0.5)ss_one_proportion(p = 0.65, p0 = 0.5)
, with the
standard deviation of the within-pair differences. 'method = "t"' solves the exact
one-sample t-test power (noncentral t) for , as [stats::power.t.test()].
ss_paired( delta, sd_diff, sig.level = 0.05, power = 0.8, deff = 1, nonresponse = 0, method = c("z", "t"), outcomes = 1, rule = c("any", "all") )ss_paired( delta, sd_diff, sig.level = 0.05, power = 0.8, deff = 1, nonresponse = 0, method = c("z", "t"), outcomes = 1, rule = c("any", "all") )
delta |
Mean difference to detect. |
sd_diff |
Standard deviation of the within-pair differences (not of either measurement). |
sig.level |
Two-sided significance level. |
power |
Power. |
deff |
Design effect. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
method |
'"z"' (normal approximation) or '"t"' (exact t-test power). |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'.
Julious SA (2004). Sample sizes for clinical trials with Normal data. Statistics in Medicine 23(12):1921-1986.
ss_paired(delta = 3, sd_diff = 8)ss_paired(delta = 3, sd_diff = 8)
The number of participants needed to estimate a proportion with a given absolute precision (half-width of the confidence interval), with optional finite-population correction, design effect and allowance for nonresponse.
ss_proportion( p, precision, conf.level = 0.95, population = NULL, deff = 1, nonresponse = 0, method = c("wald", "wilson") )ss_proportion( p, precision, conf.level = 0.95, population = NULL, deff = 1, nonresponse = 0, method = c("wald", "wilson") )
p |
Expected proportion, between 0 and 1 (use 0.5 when nothing is known). |
precision |
Absolute precision |
conf.level |
Confidence level (two-sided). |
population |
Size of the population sampled, for the finite-population correction; 'NULL' (the default) for no correction. |
deff |
Design effect (1 for simple random sampling; often 1.5 to 2 for multistage cluster samples). |
nonresponse |
Expected proportion of nonresponse or loss, from 0 up to 1. |
method |
'"wald"' (normal approximation) or '"wilson"' (Wilson score). |
The normal-approximation (Wald) size is
(Cochran 1977; Lwanga & Lemeshow 1991). 'method = "wilson"' instead solves
the Wilson score interval for , which behaves better for proportions
near 0 or 1. With a population of size , .
The result is multiplied by the design effect, rounded up, and then
inflated for nonresponse.
An object of class 'studysize': see [studysize-class]. Use [methods_text()] for a ready-to-use methods paragraph with references.
Cochran WG (1977). Sampling Techniques, 3rd ed. New York: Wiley.
Lwanga SK, Lemeshow S (1991). Sample Size Determination in Health Studies: A Practical Manual. Geneva: World Health Organization.
Wilson EB (1927). Probable inference, the law of succession, and statistical inference. Journal of the American Statistical Association 22(158):209-212.
# Prevalence about 50\%, +/- 5 percentage points, design effect 1.5, 10\% nonresponse x <- ss_proportion(p = 0.5, precision = 0.05, deff = 1.5, nonresponse = 0.1) x methods_text(x)# Prevalence about 50\%, +/- 5 percentage points, design effect 1.5, 10\% nonresponse x <- ss_proportion(p = 0.5, precision = 0.05, deff = 1.5, nonresponse = 0.1) x methods_text(x)
With ‘summary = "mean"', the groups are compared on each person’s average
over measurements with exchangeable correlation :
.
With 'summary = "slope"', on the rate of change over equally spaced
measurements across 'duration':
(Diggle et al. 2002).
ss_repeated_groups( delta, sd, times, rho, ratio = 1, summary = c("mean", "slope"), duration = NULL, sig.level = 0.05, power = 0.8, nonresponse = 0, method = c("z", "t"), outcomes = 1, rule = c("any", "all") )ss_repeated_groups( delta, sd, times, rho, ratio = 1, summary = c("mean", "slope"), duration = NULL, sig.level = 0.05, power = 0.8, nonresponse = 0, method = c("z", "t"), outcomes = 1, rule = c("any", "all") )
delta |
Difference between groups to detect: in the mean over time, or ('summary = "slope"') in the change per time unit. |
sd |
Standard deviation of one measurement. |
times |
Number of measurements per person (2 to 50). |
rho |
Correlation between a person's measurements. |
ratio |
Allocation ratio, group 2 : group 1. |
summary |
'"mean"' (average over time) or '"slope"' (rate of change). |
duration |
Follow-up time from the first to the last measurement ('summary = "slope"' only). |
sig.level |
Two-sided significance level. |
power |
Power. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
method |
'"z"', or '"t"' (exact t-test power; 'summary = "mean"' only). |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'.
Diggle PJ, Heagerty P, Liang KY, Zeger SL (2002). Analysis of Longitudinal Data, 2nd ed. Oxford: Oxford University Press.
ss_repeated_groups(delta = 3, sd = 10, times = 4, rho = 0.5) ss_repeated_groups(delta = 1, sd = 10, times = 5, rho = 0.6, summary = "slope", duration = 12)ss_repeated_groups(delta = 3, sd = 10, times = 4, rho = 0.5) ss_repeated_groups(delta = 1, sd = 10, times = 5, rho = 0.6, summary = "slope", duration = 12)
The smallest number of participants, each measured 'times' times, whose
power for the within-subject effect reaches the target. Noncentral F with
,
and , as in G*Power (Faul et al. 2007).
ss_repeated_within( f, times, rho, eps = 1, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )ss_repeated_within( f, times, rho, eps = 1, sig.level = 0.05, power = 0.8, nonresponse = 0, outcomes = 1, rule = c("any", "all") )
f |
Cohen's f for the change in means across the measurements. |
times |
Number of measurements per person (2 to 50). |
rho |
Correlation between a person's measurements. |
eps |
Nonsphericity correction |
sig.level |
Two-sided significance level. |
power |
Power. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'.
Faul F, Erdfelder E, Lang AG, Buchner A (2007). G*Power 3: a flexible statistical power analysis program for the social, behavioral, and biomedical sciences. Behavior Research Methods 39(2):175-191.
ss_repeated_within(f = 0.25, times = 3, rho = 0.5)ss_repeated_within(f = 0.25, times = 3, rho = 0.5)
Buderer's (1996) method: the number of participants with the condition
(for sensitivity) or without it (for specificity) needed to estimate the
accuracy with a given precision, , divided by the
expected prevalence (or 1 minus it) to give the total to enrol.
ss_sensitivity(se, prevalence, precision, conf.level = 0.95, nonresponse = 0) ss_specificity(sp, prevalence, precision, conf.level = 0.95, nonresponse = 0)ss_sensitivity(se, prevalence, precision, conf.level = 0.95, nonresponse = 0) ss_specificity(sp, prevalence, precision, conf.level = 0.95, nonresponse = 0)
se, sp
|
Expected sensitivity or specificity, between 0 and 1. |
prevalence |
Expected prevalence of the condition among those enrolled. |
precision |
Absolute precision, between 0 and 1. |
conf.level |
Confidence level (two-sided). |
nonresponse |
Expected proportion of nonresponse or loss, from 0 up to 1. |
An object of class 'studysize'.
Buderer NM (1996). Statistical methodology: I. Incorporating the prevalence of disease into the sample size calculation for sensitivity and specificity. Academic Emergency Medicine 3(9):895-900.
ss_sensitivity(se = 0.9, prevalence = 0.2, precision = 0.05) ss_specificity(sp = 0.85, prevalence = 0.2, precision = 0.05)ss_sensitivity(se = 0.9, prevalence = 0.2, precision = 0.05) ss_specificity(sp = 0.85, prevalence = 0.2, precision = 0.05)
,
(Julious 2004). 'method = "t"' solves the exact power of the
two-sample t-test (noncentral t, both tails) for the group size, as
[stats::power.t.test()] with 'strict = TRUE' does for equal groups, before
the design effect is applied.
ss_two_means( delta, sd, ratio = 1, sig.level = 0.05, power = 0.8, deff = 1, nonresponse = 0, method = c("z", "t"), outcomes = 1, rule = c("any", "all") )ss_two_means( delta, sd, ratio = 1, sig.level = 0.05, power = 0.8, deff = 1, nonresponse = 0, method = c("z", "t"), outcomes = 1, rule = c("any", "all") )
delta |
Difference in means to detect. |
sd |
Common standard deviation. |
ratio |
Allocation ratio, group 2 : group 1. |
sig.level |
Two-sided significance level. |
power |
Power. |
deff |
Design effect. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
method |
'"z"' (normal approximation) or '"t"' (exact t-test power). |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'.
Julious SA (2004). Sample sizes for clinical trials with Normal data. Statistics in Medicine 23(12):1921-1986.
ss_two_means(delta = 5, sd = 10) ss_two_means(delta = 5, sd = 10, method = "t")ss_two_means(delta = 5, sd = 10) ss_two_means(delta = 5, sd = 10, method = "t")
The normal-approximation sample size for a two-sided test of two
proportions with allocation ratio = group 2 : group 1 (Fleiss,
Levin & Paik 2003): , .
ss_two_proportions( p1, p2, ratio = 1, sig.level = 0.05, power = 0.8, deff = 1, nonresponse = 0, continuity = FALSE, outcomes = 1, rule = c("any", "all") )ss_two_proportions( p1, p2, ratio = 1, sig.level = 0.05, power = 0.8, deff = 1, nonresponse = 0, continuity = FALSE, outcomes = 1, rule = c("any", "all") )
p1, p2
|
Expected proportions in group 1 and group 2. |
ratio |
Allocation ratio, group 2 : group 1. |
sig.level |
Two-sided significance level. |
power |
Power. |
deff |
Design effect. |
nonresponse |
Expected proportion of nonresponse or loss to follow-up. |
continuity |
Apply Yates' continuity correction (equal groups only). |
outcomes |
Number of primary outcomes (1 to 10). With more than one, 'rule' says what counts as success. |
rule |
'"any"': success if any one outcome is significant (each tested at 'sig.level / outcomes', Bonferroni); '"all"': co-primary outcomes that must all succeed (each planned with power 'power^(1/outcomes)'). |
An object of class 'studysize'.
Fleiss JL, Levin B, Paik MC (2003). Statistical Methods for Rates and Proportions, 3rd ed. Hoboken: Wiley.
ss_two_proportions(p1 = 0.30, p2 = 0.15) ss_two_proportions(p1 = 0.30, p2 = 0.15, ratio = 2, nonresponse = 0.1)ss_two_proportions(p1 = 0.30, p2 = 0.15) ss_two_proportions(p1 = 0.30, p2 = 0.15, ratio = 2, nonresponse = 0.1)
Every 'ss_*()' function returns a list of class 'studysize' with:
The calculation's identifier.
The assumptions, as given.
The unrounded size from the formula (per group 1 for two-group designs; events for the log-rank test; person-time for rates; clusters per arm for cluster trials).
Completed observations needed in all, before nonresponse.
Recruitment target per group, after nonresponse.
The total recruitment target.
What is counted (participants, pairs).
Cautions about the calculation.
Method-specific details (events, clusters, design effect).