Sampsize |
Sample size and Power | |
Version 0.6 | |
September 29, 2003 |
Philippe GLAZIOU
glaziou@gmail.com
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
This document is free; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This document is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied war ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Te mple Place, Suite 330, Boston, MA 02111-1307, USA.
sampsize - Computes sample size and power
sampsize
[-h] [-v] [-onesided] [-onesample] [-matched] [-cc continuity] [-pop pop] [-e precision] [-pr prevalence] [-level level] [-alpha alpha] [-power power] [-c ratio] [-or odds_ratio] [-exp exposed] [-cp comp] [-means means] [-rho rho] [-d delta] [-nob observed] [-bi binomial] [-n sample] [-obsclus obsclus] [-numclus numclus]
1 value between 0.0 and oo.
Default: `
0'
1 value between 0.0 and 100.
1 value between 0.0 and 100.
Default: `
50'
1 value between 50.0 and 100.
Default: `
95'
1 value between 0.0 and 100.
Default: `
5'
1 value between 50.0 and 100.
Default: `
90'
1 integer value between 0 and oo with case control options, or
1 value between 0.0 and oo with other relevant options,
Default: `
1'
1 value between 0.0 and oo.
1 value between 0.0 and 100.
2 consecutive values between 0.0 and 100.
3 values if onesample is selected or else, 4 consecutive values.
1 value between 0.0 and 1, default 0
1 integer value between 1 and 10000.
2 integer values between 0 and oo.
1 integer value > 0
1 integer value > 0
1 value between 0.0 and oo
Sampsize computes sample size and power for prevalence studies, sample size and power for one-sample and two-sample comparative studies of percentages and means, and for unmatched and 1:1 matched case-control studies.
The following options are relevant to simple prevalence studies:
The population size is the total size of the population from which a sample will be drawn for a prevalence survey. If the population size is small, the correction for finite population will result in a reduced sample size. A prevalence study will need either the -e option for precision, or the -nob option to specify a finite number of events (see below).
Entering 50 (50%) for the estimated prevalence (-pr 50), which is the default value, will result in the highest estimated sample size. Entering 0 for the population size (-pop 0) will result in the programme using an infinite population size. If a null prevalence is entered ( -pr 0), sampsize returns the estimated sample size needed for a 95% (default) confidence interval upper limit that is equal to the entered precision (option -e). Any other confidence interval may be selected instead of the 95% confidence interval, using the option -level. Sampsize will display the binomial exact confidence interval using the returned sample size unless a finite population size is specified. It may happen that this exact interval is larger than the expected interval (prevalence plus or minus precision), when the number of successful events is lower than 5, or when sample size minus that number is lower than 5, due to the lack of precision of the normal approximation formula with small numbers. In thoses instances, it is advisable to test different hypotheses of sample size and hypothetical numbers of successful binomial events using the -bi option (see below).
This is a variation over the previous design: prevalence is low and the capacity to deal with a large sample often necessary to achieve a reasonable precision of the measured estimate is limited. We will rather want to detect with probability specified with -level at least n sampled units with the studied characteristic, given a probability of occurence = prevalence (-pr). The option -nob instructs sampsize to return the sample size needed to observe at least -nob successful events, given a -pr probability of occurence. Relevant options are:
The first design options may lead to small samples and the approximations used to estimate sample size are known to be non valid if less than 5 sampled units are expected to have the studied characteristic (equally problemactic: all sampled units minus 5 or less have that characteristic). One alternative approach is to calculate the binomial exact confidence intervals that result from different sets of numbers. Relevant options are:
Sampsize estimates the required sample size for studies comparing two groups. Sampsize can be used when comparing means or proportions for simple studies where only one measurement of the outcome is planned. Sampsize computes the sample size for two-sample comparison of means, where the postulated values of the means and standard deviations are -means m1 m2 sd1 sd2; one-sample comparison of mean to hypothesized value (option -onesample must be specified and only three parameters to the option -means are allowed in one-sample tests: m1, m2 and sd1); two-sample comparison of proportions (option -cp where the postulated values of the proportions are #1 and #2); and one-sample comparison of proportion to hypothesized value (option -onesample should be specified), where the hypothesized proportion (null hypothesis) is #1 and the postulated proportion (alternative hypothesis) is #2. Default power is 90%. If -n is specified, sampsize will compute power.
In the case of a cluster sampling design, a sample of natural groups of individuals is selected, rather than a random sample of the individuals themselves. Observations are no longer independant as we would expect had they been drawn randomly from the population. Nonindependance is measured by the intraclass correlation, which is specified with option -rho (between 0 and 1). One may then specify -numclus, the number of clusters (for instance, the number of physicians who will recruit the patients: typically, the intraclass orrelation will be fairly small, often between 0 and 0.05), or alternatively, -obsclus, the minimum number of observations per cluster. The larger the number of clusters and the fewer observations per cluster, the less the effect on the standard error estimates. A sample of 250 consisting of 50 clusters with 5 observations per cluster will have better power than the same sample size consisting of 25 clusters with 10 observations per cluster. In fact, with only one observation per cluster, we are back to a simple random sample. If there is no intraclass correlation, there will be no increase in the sample size estimate.
By default, no continuity correction is applied when computing sample size or power for the comparison of two percentages. However, the correction may be applied with option -cc . The correction will result in a greater sample size and smaller power. Simulations showed that the correction is most often too conservative (Alzola C and Harrell F, An introduction to S and the Hmisc and Design Libraries: http://hesweb1.med.virginia.edu/biostat/s/splus.html).
Relevant options are (either -cp or -means must be specified, not both):
To specify a case-control design, we need to type the option -exp, which specifies the percentage of exposed controls. If we add the option -or, the odds-ratio that that we wish to detect, sampsize will return the sample size for an unmatched design (option -c specifies the ratio of controls/cases, the default ratio is 1). The option -matched may be used to specify a 1:1 matched study design (-c may not be used with -matched). If we specify -exp, -or, and -n, sampsize will return the power of the specified design. If one specifies -exp and -n, which is the number of cases, sampsize will return the minimum detectable odds-ratio greater than one and the maximum detectable odds-ratio lower than one, an alternative to the power determination. Relevant options are:
The goal of an equivalence trial is to prove that two quantities are equal. The hypothesis framework for an equivalence trial requires the specification of no difference in the alternative and a difference in the null. It contains an additional parameter delta, -d, to indicate the maximum clinical difference allowed for an experimental therapy to be considered equivalent with a standard therapy. Binomial endpoints are defined as the positive difference of the probability of success for the standard group (ps) and the probability of success for the experimental group (pt) of patients. These probabities are entered with -cp #ps #pt (percentages), and delta is entered as a percentage. In the case of a continuous endpoint, delta indicates the maximum clinical difference allowed for the comparison of two means, and is entered using the -d option. Means and standard deviations are to be entered the usual way with -means ms me ss se, with ms and me the means in the standard and experimental group, respectively, and ss and se the standard deviations.
There is a general misconception that it requires a larger sample to prove equivalence than difference. The veracity of this assumption is situation-specific and dependant upon the degree of difference, delta, one is willing to allow so that the standard and experimental treatments may still be considered equivalent. Relevant options are:
Assumptions: Precision = 5.00 % Prevalence = 50.00 % Population size = infinite 95% Confidence Interval specified limits [ 45% -- 55% ] (these limits equal prevalence plus or minus precision) Estimated sample size: n = 385 95% Binomial Exact Confidence Interval with n = 385 and n * prevalence = 193 observed events: [45.0212% -- 55.2365% ]
Assumptions: Precision = 5.00 % Prevalence = 50.00 % Population size = 1500 95% Confidence Interval specified limits [ 45% -- 55% ] (these limits equal prevalence plus or minus precision) Estimated sample size: n = 306
Assumptions: Precision = 4.00 % Prevalence = 10.00 % Population size = 2500 90% Confidence Interval specified limits [ 6% -- 14% ] (these limits equal prevalence plus or minus precision) Estimated sample size: n = 144
Assumptions: Precision = 2.00 % Prevalence = 0.00 % Population size = infinite A null prevalence was entered, we assume here that the observed prevalence in the sample will be null, and compute the sample size for an upper limit of the confidence interval equal to the entered precision. The population size is not taken into account even if a finite size was entered. Sample sizes are calculated using the binomial exact method. 97.5% one-sided Confidence Interval upper limit = 2.00 Estimated sample size: n = 183
Assumptions: Precision = 2.00 % Prevalence = 0.00 % Population size = infinite A null prevalence was entered, we assume here that the observed prevalence in the sample will be null, and compute the sample size for an upper limit of the confidence interval equal to the entered precision. The population size is not taken into account even if a finite size was entered. Sample sizes are calculated using the binomial exact method. 95% one-sided Confidence Interval upper limit = 2.00 Estimated sample size: n = 149
Assumptions: prevalence = 10% minimum number of successes = 5 in the sample with probability = 95% Estimated sample size: n = 90
Assumptions: number of observations = 10 number of successes = 1 Binomial Exact 95% Confidence Interval: [0.252858% -- 44.5016%]
Estimated sample size for one-sample comparison of percentage to hypothesized value Test Ho: p = 50%, where p is the percentage in the population Assumptions: alpha = 5% (two-sided) power = 80% alternative p = 75% Estimated sample size: n = 29
'
s opinions of
the President'
s performance. Specifically, we want to
determine whether members of the President'
s party have a
different opinion from people with another party affiliation. We
estimate that only 25% of members of the President'
s party
will say that the President is doing a poor job, whereas 40% of
other parties will rate the President'
s performance as poor.
We compute the sample size for alpha = 5% (two-sided) and power =
90%:
Estimated sample size for two-sample comparison of percentages Test H: p1 = p2, where p1 is the percentage in population 1 and p2 is the percentage in population 2 Assumptions: alpha = 5% (two-sided) power = 90% p1 = 25% p2 = 40% Estimated sample size: n1 = 216 n2 = 216
'
s performance, we realize that we can sample only
n1 = 300 members of the President'
s party and a sample of n2
= 150 members of other parties, due to time constraints. We wish to
compute the power of our survey:
Estimated power for two-sample comparison of percentages Test Ho: p1 = p2, where p1 is the percentage in the population 1 and p2 is the percentage in the population 2 Assumptions: alpha = 5 (two-sided) p1 = 25% p2 = 40% sample size n1 = 300 sample size n2 = 150 n2/n1 = 0.5 Estimated power: power = 87.8976%
Estimated sample size for two-sample comparison of percentages Test H: p1 = p2, where p1 is the percentage in population 1 and p2 is the percentage in population 2 Assumptions: alpha = 5% (two-sided) power = 80% p1 = 20% p2 = 30% Estimated sample size: n1 = 313 n2 = 313
Estimated sample size for two-sample comparison of percentages Test H: p1 = p2, where p1 is the percentage in population 1 and p2 is the percentage in population 2 Assumptions: alpha = 5% (two-sided) power = 80% p1 = 20% p2 = 30% Estimated sample size: n1 = 313 n2 = 313 Sample size adjusted for cluster design: Intraclass correlation = 0.1 Average obs. per cluster = 10 Minimum number of clusters = 119 Estimated sample size per group: n1 (corrected) = 595 n2 (corrected) = 595
Sample size adjusted for cluster design: Error: for rho = 0.1, the minimum number of clusters possible is: numclus = 63
Sample size adjusted for cluster design: Intraclass correlation = 0.05 Average obs. per cluster = 69 Minimum number of clusters = 40 Estimated sample size per group: n1 (corrected) = 1378 n2 (corrected) = 1378
Estimated sample size for one-sample comparison of mean to hypothesized value Test Ho: m = 0, where m is the mean in the population Assumptions: alpha = 2.5 (one-sided) power = 95 alternative m = -10 sd = 20 Estimated sample size: n = 52
Estimated power for one-sample comparison of mean to hypothesized value Test Ho: m = 0%, where m is the mean in the population Assumptions: alpha = 1% (one-sided) alternative m = -10 sd = 20 sample size = 60 Estimated power: power = 93.9024%
Estimated sample size for two-sample comparison of means Test Ho: m1 = m2, where m1 is the mean in population 1 and m2 is the mean in population 2 Assumptions: alpha = 5 (two-sided) power = 80 m1 = 132.86 m2 = 127.44 sd1 = 15.34 sd2 = 18.23 n2/n1 = 2 Estimated sample size: n1 = 108 n2 = 216
Estimated power for two-sample comparison of means Test Ho: m1 = m2, where m1 is the mean in the population 1 and m2 is the mean in the population 2 Assumptions: alpha = 5% (two-sided) m1 = 132.86 m2 = 127.44 sd1 = 15.34 sd2 = 18.23 sample size n1 = 100 sample size n2 = 100 n2/n1 = 1 Estimated power: power = 62.3601%
Estimated sample size for two-sample comparison of means Test Ho: m1 = m2, where m1 is the mean in population 1 and m2 is the mean in population 2 Assumptions: alpha = 5 (two-sided) power = 80 m1 = 132.86 m2 = 127.44 sd1 = 15.34 sd2 = 18.23 n2/n1 = 2 Estimated sample size: n1 = 108 n2 = 216 Sample size adjusted for cluster design: Intraclass correlation = 0.02 Average obs. per cluster = 58 Minimum number of clusters = 12 Estimated sample size per group: n1 (corrected) = 232 n2 (corrected) = 464
The design effect is rather important despite a small intraclass correlation, due to the small number of clusters. Sampsize returned n1 = 232 and n2 = 464, more than twice the initial sample size.
Assumptions: Odds ratio = 2 Exposed controls = 20% Alpha risk = 5% Power = 90% Controls / Case ratio = 3 Total exposed = 23.3333% Estimated sample size: Number of cases = 150 Number of controls = 450 Total = 600
Assumptions: Odds ratio = 2 Exposed controls = 20% Alpha risk = 5% Power = 90% Probability of an exposure-discordant pair = 40% Estimated sample size (number of pairs): Number of exposure discordant-pairs = 91 Number of pairs = 226 Total sample size = 452
Spontaneous | Controls | |
abortions | ||
PIA: | ||
yes | 171 | 90 |
no | 303 | 165 |
Total: | 474 | 255 |
The power of the study for detecting a relative risk of R = 1.5 is calculated as follows: , percentage exposed in controls = :
Assumptions: Odds ratio = 1.5 Exposed controls = 35.29% Alpha risk = 5% Controls / Case ratio = 0.538 Total exposed = 41.6005% Number of cases = 474 Number of controls = 255 Total = 729 Estimated power: power = 72.0774%
Assumptions: Exposed controls = 35% One-sided alpha risk = 5% Power = 90 Number of cases = 365 Number of controls = 365 Total = 730 Estimated smallest and highest detectable odds-ratio: Highest odds-ratio < 1 = 0.623181 Smallest odds-ratio > 1 = 1.55439
Estimated sample size for two-sample non-inferiority comparison of percentages Test H0: p2 < p1 - delta, where p1 is the percentage in population 1, p2 is the percentage in population 2, and delta is the critical value Assumptions: alpha = 5% (two-sided) power = 90% p1 = 90% p2 = 90% delta = 10% Estimated sample size per group: n = 155
The most recent distributions of sampsize can be found at:
sampsize project home page:
Some parts of sampsize are translated and adapted from publicly available code written in the stata language (Statacorp Inc.).
Sampsize |
Sample size and Power | |
Version 0.6 | |
September 29, 2003 |
This document was generated using the LaTeX2HTML translator Version 2K.1beta (1.48)
Copyright © 1993, 1994, 1995, 1996,
Nikos Drakos,
Computer Based Learning Unit, University of Leeds.
Copyright © 1997, 1998, 1999,
Ross Moore,
Mathematics Department, Macquarie University, Sydney.
The command line arguments were:
latex2html -split 1 manual
The translation was initiated by Philippe Glaziou on 2003-09-29