Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sample size for comparison on means in RCT with baseline adjustment (ie. ANCOVA)

    Hi Statalist

    Question:
    Is anyone able to tell me what the code is for calculating the sample size for a two independent group baseline adjusted 'ANCOVA' design using one of the newer Power and Sample Size commands?

    Background:
    Many randomised controlled trials with a continuous outcome adjust for the same variable measured at baseline. This analysis, known as analysis of covariance (ANCOVA), has the advantage of a gain in efficiency so that the required sample size equals the sample size for a independent t-test multiplied by (1 - r2), where r = the correlation between the baseline and follow-up measures.
    (r is also known sometimes as the intraclass correlation coefficient (ICC) or test-retest correlation). [Ref https://doi.org/10.1016/j.jclinepi.2006.02.007]

    Stata used to use (and still accepts) the sampsi command to calculate the sample size required for this design. For example the following command would be used for a two-arm parallel group trial looking to detect a difference of 4 points between Control and Treatment groups, with a common standard deviation of 15 points and r of 0.8, and with power .9 at a two-sided alpha of 0.5.

    Code:
    sampsi 0 4, sd(15) r01(0.8) pre(1) post(1)
    The output from this command is very informative, and gives the sample sizes for analysis using; follow-up measurements only (POST), change in measures between baseline and follow-up (CHANGE), and follow-up measurements with baseline adjustment (ANCOVA).


    Thanks very much,

    Jonathan

  • #2
    I don't see this as a canned option in the new power command. You are left with using sampsi, making a power usermethod, or multiplying the results from power twomeans by (1-r2). The latter gives the same answer as sampsi.

    Comment


    • #3
      I'd recommend bringing this to StataCorp's attention. Maybe they can add an illustration to the help file for power usermethod of how to perform the power analysis for ANCOVA with various numbers of pre- and posttreatment observations, and various correlations between them. It would also be a nice Stata Blog topic.

      Comment


      • #4
        Note there is an improvement for small sample sizes over the suggested design factor above. It's in this paper:

        Shan and Ma, J Biomet Biostat 2014, 5:1
        "A Comment on Sample Size Calculation for Analysis of Covariance in
        Parallel Arm Studies"
        DOI: 10.4172/2155-6180.1000184

        Borm et al., (2007) A simple sample size formula for analysis of covariance in
        randomized clinical trials. Journal of Clinical Epidemiology 60 1234-1238

        I was playing around below to reproduce some of their table output. The Shan paper could be the basis for a power usermethod for ANCOVA.

        Code:
        clear
        local n1 = 64
        local n2 = `n1'
        local N = 2*`n1'
        local mu1 = 0
        local mu2 = 0.5
        local sd = 1
        local yvar = `sd'^2
        local alpha = 0.05
        local rho = 0.1
        local central_F_crit = invFtail(1, (`N'-3), `alpha')
        local central_F_prob = Ftail(1, (`N'-3), `central_F_crit')
        display "`central_F_crit'" // critical F stat at alpha
        display "`central_F_prob'" // tail probability above crit F stat
        local var_within = (1 - `rho'^2)*`yvar'
        local mu = `n1'*`mu1'/`N' + `n2'*`mu2'/`N'
        local var_between = `n1'/`N'*(`mu1' - `mu')^2 + `n2'/`N'*(`mu2' - `mu')^2
        local ncp = `N'*`var_between'/`var_within'
        local noncentral_F_prob = nFtail(1, (`N'-3), `ncp', `central_F_crit')
        display "`noncentral_F_prob'" // power

        Comment


        • #5
          Here's a basic power usermethod. You name it power_cmd_myancova.ado and put it in your c:\ado\personal for example.

          Code:
          // evaluator
          program power_cmd_myancova, rclass
              version 15.1
              syntax , n(integer) ///
                       sd(real) ///
                       alpha(real) ///
                       mu1(real) ///
                       mu2(real) ///
                       cor(real)
          
              /* compute power */
              local n1 = `n'/2
              local n2 = `n1'
              local central_F_crit = invFtail(1, (`n'-3), `alpha')
              local var_within = (1 - `cor'^2)*`sd'^2
              local mu = `n1'*`mu1'/`n' + `n2'*`mu2'/`n'
              local var_between = `n1'/`n'*(`mu1' - `mu')^2 + `n2'/`n'*(`mu2' - `mu')^2
              local ncp = `n'*`var_between'/`var_within'
              tempname power
              scalar `power' = nFtail(1, (`n'-3), `ncp', `central_F_crit')
          
              /* return results */
              return scalar power = `power'
              return scalar N = `n'
              return scalar alpha = `alpha'
          end
          Output might look like below. Note N is total sample size here.

          Code:
          . power myancova, n(20(20)80) sd(1) alpha(.05) mu1(0) mu2(0.5) cor(0.6)
          
          Estimated power
          Two-sided test
          
            +-------------------------+
            |   alpha   power       N |
            |-------------------------|
            |     .05   .2614      20 |
            |     .05   .4861      40 |
            |     .05   .6627      60 |
            |     .05   .7882      80 |
            +-------------------------+
          
          . power myancova, n(80(1)90) sd(1) alpha(.05) mu1(0) mu2(0.5) cor(0.6)
          
          Estimated power
          Two-sided test
          
            +-------------------------+
            |   alpha   power       N |
            |-------------------------|
            |     .05   .7882      80 |
            |     .05   .7933      81 |
            |     .05   .7982      82 |
            |     .05   .8031      83 |
            |     .05   .8079      84 |
            |     .05   .8125      85 |
            |     .05   .8171      86 |
            |     .05   .8216      87 |
            |     .05   .8259      88 |
            |     .05   .8302      89 |
            |     .05   .8344      90 |
            +-------------------------+

          Comment


          • #6
            Hi Dave

            Thank you so much for your helpful comments, reference and usermethod. In the past it has always taken me 10 or so minutes of hunting around the Power and Sample Size dialogue boxes before I remembered I had to use the sampsi command. I'll definitely add your power usermethod to my toolbox!

            Comment

            Working...
            X