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

Title

Executes sample size/power calculations multiple times and producesgraphical results

Syntax

samplesize[,options]

optionsDescription ------------------------------------------------------------------------- Mainnorestorereplaces 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.onesamplespecifies that a one-sample test is assumed.onesidedspecifies that a one-sided test is assumed.method(string)specifies which analysis method to use.nocontinuityspecifies 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.mlabelspecifies that the values of each calculation are displayed in the graph. twoway_options -------------------------------------------------------------------------

DescriptionMost of STATA's sample size calculation programs do not allow

numlistsfor the options.samplesizeis designed to allownumliststo do multiple calculations using various sample size commands. The resulting sample sizes or power calculations are then drawn using atwowaygraph.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 commandTo 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 +-------------------------------------------------------------

norestorereplaces the current dataset with a dataset containing the samplesize calculations.

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

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

n1(numlist)size of sample 1. Forsampsi_mccthis 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 isa(0.05).

power(numlist)power of test; default isp(0.9).

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

ratio(numlist)ratio of sample sizes; default isr(1).

onesampleone-sample test; default is two-sample.

onesidedone-sided test; default is two-sided.

method(string)analysis method ispost,change,ancova; default ism(all)although onlyancovawill be plotted.

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

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

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

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

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

r01(numlist)correlation between baseline and follow-up measurements; default isr01(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 andvarmethod(sdy)uses the standard deviation of the Y's, the default uses a direct estimate of the residual sdsd1(#).+---------------------+ ----+ sampsi_mcc options +----------------------------------------------

[sampsi_mcc option]

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

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

p0(numlist)specifies the probability of exposure in the controls; default isp0(0.5).+-----------------+ ----+ General Options +--------------------------------------------------

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

mlabelspecifies 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.

ExamplesThe 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)

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

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

Related commands:See Alsosampsi 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)