help samplesize
-------------------------------------------------------------------------------

Title

Executes sample size/power calculations multiple times and produces graphical results

Syntax

samplesize [, options]

options Description ------------------------------------------------------------------------- Main norestore replaces the current dataset with a dataset containing the samplesize calculations. null(numlist) specifies the "null value". alt(numlist) specifies the "alternative value". n1(numlist) specifies the size of sample 1. n2(numlist) specifies the size of sample 2. sd1(numlist) specifies the standard deviation of sample 1. sd2(numlist) specifies the standard deviation of sample 2. alpha(numlist) specifies the significance level of test. power(numlist) specifies the power of the test. rho(numlist) solve(string) specifies whether to solve for the sample size or power. ratio(numlist) specifies the ratio of sample sizes. onesample specifies that a one-sample test is assumed. onesided specifies that a one-sided test is assumed. method(string) specifies which analysis method to use. nocontinuity specifies whether to not use a continuity correction. pre(numlist) specifies the number of baseline measurements. post(numlist) specifies the number of follow-up measurements. r0(numlist) specifies the correlation between baseline measurements. r1(numlist) specifies the correlation between follow-up measurements. r01(numlist) specifies the correlation between baseline and follow-up measurements.

sampsi_reg options sy(numlist) specifies the standard deviation of the Y's. sx(numlist) specifies the standard deviation of the X's. yxcorr(numlist) specifies the correlation between Y's and X's. varmethod(string) specifies the method for calculating the residual standard deviation.

sampsi_mcc options m(numlist) specifies the number of matched controls per case. phi(numlist) specifies the correlation of exposure between pairs of subjects in the case-control matched set. p0(numlist) specifies the probability of exposure in the controls.

General Options command(string) specifies which sample size command to use. xvar(string) specifies the variable to be used as the x-variable in the plots. mlabel specifies that the values of each calculation are displayed in the graph. twoway_options -------------------------------------------------------------------------

Description

Most of STATA's sample size calculation programs do not allow numlists for the options. samplesize is designed to allow numlists to do multiple calculations using various sample size commands. The resulting sample sizes or power calculations are then drawn using a twoway graph.

At present the following commands are supported (more will be introduced):

Help File Examples sampsi Two-sample t-test sampsi_reg Linear regression sampsi_mcc Matched Case-Control sampsi_rho Pearson Correlation

Please email me if you want the introduction of other sample size commands.

Updating this command

To obtain the latest version click the following to uninstall the old version ssc uninstall samplesize And click here to install the new version ssc install samplesize

Options

+------+ ----+ Main +-------------------------------------------------------------

norestore replaces the current dataset with a dataset containing the samplesize calculations.

null(numlist) specifies the "null value", #1 in sampsi.

alt(numlist) specifies the "alternative value", #2 in sampsi.

n1(numlist) size of sample 1. For sampsi_mcc this is the number of cases.

n2(numlist) size of sample 2.

sd1(numlist) standard deviation of sample 1.

sd2(numlist) standard deviation of sample 2.

alpha(numlist) significance level of test; default is a(0.05).

power(numlist) power of test; default is p(0.9).

solve(string) specifies whether to solve for the sample size or power; default is s(n) solves for n and the only other choice is s(power) solves for power.

ratio(numlist) ratio of sample sizes; default is r(1).

onesample one-sample test; default is two-sample.

onesided one-sided test; default is two-sided.

method(string) analysis method is post, change, ancova; default is m(all) although only ancova will be plotted.

nocontinuity do not use continuity correction for two-sample test on proportions.

pre(numlist) number of baseline measurements; default is pre(0).

post(numlist) number of follow-up measurements; default is post(1).

r0(numlist) correlation between baseline measurements; default is r0(0).

r1(numlist) correlation between follow-up measurements; default is r1(0).

r01(numlist) correlation between baseline and follow-up measurements; default is r01(0).

+---------------------+ ----+ sampsi_reg options +----------------------------------------------

[sampsi_reg option] sy(numlist) the standard deviation of the Y's.

[sampsi_reg option] sx(numlist) the standard deviation of the X's.

[sampsi_reg option] yxcorr(numlist) the correlation between Y's and X's.

[sampsi_reg option] varmethod(string) specifies the method for calculating the residual standard deviation. varmethod(r) uses the Y-X correlation and varmethod(sdy) uses the standard deviation of the Y's, the default uses a direct estimate of the residual sd sd1(#).

+---------------------+ ----+ sampsi_mcc options +----------------------------------------------

[sampsi_mcc option] m(numlist) specifies the number of matched controls per case; default is m(1).

[sampsi_mcc option] phi(numlist) specifies the correlation of exposure between pairs of subjects in the case-control matched set; default is phi(0.2).

[sampsi_mcc option] p0(numlist) specifies the probability of exposure in the controls; default is p0(0.5).

+-----------------+ ----+ General Options +--------------------------------------------------

command(string) specifies which sample size command to use, the default is sampsi.

mlabel specifies that the values of each calculation are displayed in the graph.

xvar(string) specifies the variable to be used as the x-variable in the resulting plots. The default is the variable with the most values, this will work well for the majority of calculations.

Examples

The full interactive version runs from a dialog box db samplesize (to be distributed in the near future)

Two-sample comparison of mean1 to mean2. Compute sample sizes with n2/n1 = 2: samplesize, null(132.86) alt(127.44) p(0.8) r(2(2)10) sd1(15.34) sd2(18.23) Compute power with n1 = n2, sd1 = sd2, and alpha = 0.01 one-sided: samplesize, null(5.6) alt(6.1) n1(100) sd1(1.5) a(0.01(0.01)0.05) onesided

One-sample comparison of mean to hypothesized value = 180. Compute sample size: samplesize, null(180) alt(211) sd(46(1)60) onesam One-sample comparison of mean to hypothesized value = 0. Compute power: samplesize, null(0) alt(-2.5) sd(4(0.2)5) n(25(10)55) onesam

Two-sample comparison of proportions. Compute sample size with n1 = n2 (i.e., ratio = 1, the default) and power = 0.9 (the default): samplesize, null(0.25) alt(0.4(0.01)0.6) Compute power with n1 = 500 and ratio = n2/n1 = 0.5: samplesize, null(0.25) alt(0.4) n1(300) r(0.5(0.1)0.9)

One-sample comparison of proportion to hypothesized value = 0.5: samplesize, null(0.5) alt(0.75) power(0.8(0.01)0.9) onesample Compute power: samplesize, null(0.5) alt(0.6) n1(200(10)400) onesam s(power)

Repeated Measures samplesize, null(498) alt(483(0.2)487) sd1(20.2) sd2(19.5) method(change) pre(1) post(3) r1(.1(.1).9) solve(n) Compute power: samplesize, null(498) alt(485) sd1(20.2) sd2(19.5) method(change) pre(1) post(1(1)10) r1(.7) n1(15) n2(15) solve(power)

Linear Regression samplesize, null(0) alt(0.2(0.1)0.8) solve(n) command(sampsi_reg) Compute power: samplesize, null(0) alt(0.6(0.1)1.6) sx(0.5(0.2)1.5) solve(power) command(sampsi_reg)

Matched Case-control Study. samplesize, alt(1.2(0.1)1.8) m(1(1)5) solve(n) command(sampsi_mcc)

How to display the exact sample sizes in the graph samplesize, alt(1.2(0.1)1.8) m(1(1)5) solve(n) command(sampsi_mcc) mlabel

Compute power: samplesize, alt(1.2(0.1)3) phi(0.2(0.2)0.8) n1(100) solve(power) command(sampsi_mcc)

Pearson Correlation samplesize, null(0) alt(0.2(0.1)0.8) solve(n) command(sampsi_rho) Compute power: samplesize, null(0) alt(0.6(0.05)0.9) a(0.05 0.01) solve(power) command(sampsi_rho)

Author

Adrian Mander, MRC Human Nutrition Research, Cambridge, UK.

Email adrian.mander@mrc-hnr.cam.ac.uk

See Also Related commands:

sampsi sampsi_reg (if installed) sampsi_mcc (if installed) sampsi_rho (if installed) sampclus (if installed) xsampsi (if installed) artmenu (if installed) mvsampsi (if installed) studysi (if installed) sskapp (if installed) ssizebi (if installed) optfixn (if installed) calcssi (if installed) ggipower (if installed) sampncti (if installed)