Skip to content

Instantly share code, notes, and snippets.

@vikjam
Created January 22, 2017 15:57
Show Gist options
  • Save vikjam/31acc9492c2dda57195448771365d76e to your computer and use it in GitHub Desktop.
Save vikjam/31acc9492c2dda57195448771365d76e to your computer and use it in GitHub Desktop.
sampsi versus power in Stata
* Two-sample comparison of mean1 to mean2. Compute sample sizes with n2/n1 = 2:
sampsi 132.86 127.44, p(0.8) r(2) sd1(15.34) sd2(18.23)
power twomeans 132.86 127.44, p(0.8) nratio(2) sd1(15.34) sd2(18.23)
@vikjam
Copy link
Author

vikjam commented Jan 22, 2017

Not quite the same,

. sampsi 132.86 127.44, p(0.8) r(2) sd1(15.34) sd2(18.23)

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 =   0.0500  (two-sided)
         power =   0.8000
            m1 =   132.86
            m2 =   127.44
           sd1 =    15.34
           sd2 =    18.23
         n2/n1 =     2.00

Estimated required sample sizes:

            n1 =      108
            n2 =      216

. power twomeans 132.86 127.44, p(0.8) nratio(2) sd1(15.34) sd2(18.23)

Performing iteration ...

Estimated sample sizes for a two-sample means test
Satterthwaite's t test assuming unequal variances
Ho: m2 = m1  versus  Ha: m2 != m1

Study parameters:

        alpha =    0.0500
        power =    0.8000
        delta =   -5.4200
           m1 =  132.8600
           m2 =  127.4400
          sd1 =   15.3400
          sd2 =   18.2300
        N2/N1 =    2.0000

Estimated sample sizes:

            N =       327
           N1 =       109
           N2 =       218

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment