Announcement

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

  • Stata 15: Two -estat esize- bugs still not fixed

    I wrote two DO-files to test whether some estat esize problems that have been discussed in the past have been fixed in Stata 15. Cutting to the chase, no, they have not been fixed.

    In summary:
    1. Following one-way (independent groups) ANOVA, estat esize, omega computes epsilon^2, not omega^2.
    2. Following one-way repeated measures ANOVA, estat esize computes a partial eta^2, but labels it eta^2.
    Some reference links are included in the output below, but the hyperlinks probably won't work there, so I copy them here: Here is the output from my two DO-files.
    Code:
    . do "C:\bw\Stata\DO files\ANOVA\Oneway_ANOVA_omegaSq_Bug.do"
    
    . * Date:  15-Jun-2017
    . * File:  Oneway_ANOVA_omegaSq_test.DO
    . * Author:  Bruce Weaver, [email protected]
    . * Stata version used:  Stata/IC v15 (Windows, 64-bit)
    .
    . * Q. Following one-way ANOVA, does -estat esize, omega-
    . *    actually compute epsilon^2?
    .
    . clear
    
    . use https://stats.idre.ucla.edu/stat/stata/faq/crf24
    (CRF Example - Kirk, 1st Edition)
    
    . *https://stats.idre.ucla.edu/stata/faq/
    . anova y b
    
                             Number of obs =         32    R-squared     =  0.8259
                             Root MSE      =    1.21008    Adj R-squared =  0.8072
    
                      Source | Partial SS         df         MS        F    Prob>F
                  -----------+----------------------------------------------------
                       Model |      194.5          3   64.833333     44.28  0.0000
                             |
                           b |      194.5          3   64.833333     44.28  0.0000
                             |
                    Residual |         41         28   1.4642857  
                  -----------+----------------------------------------------------
                       Total |      235.5         31   7.5967742  
    
    . *ereturn list
    . * Hand calculation of eta^2:
    . display "eta^2 = " e(ss_1)/(e(ss_1)+e(rss))
    eta^2 = .82590234
    
    . estat esize // eta^2 computed by Stata
    
    Effect sizes for linear models
    
    -------------------------------------------------------------------
                 Source |   Eta-Squared     df     [95% Conf. Interval]
    --------------------+----------------------------------------------
                  Model |   .8259023         3     .6545609    .8756227
                        |
                      b |   .8259023         3     .6545609    .8756227
    -------------------------------------------------------------------
    
    . * Hand calculations of omega^2 & epsilon^2:
    . local sst = e(mss)+e(rss) // SS_total = SS_model + SS_residual
    
    . local msr = e(rss)/e(df_r) // MS_residual
    
    . display "  omega^2 = " (e(ss_1)-e(df_1)*`msr')/(`sst'+`msr')
      omega^2 = .80226074
    
    . display "epsilon^2 = " (e(ss_1)-e(df_1)*`msr')/`sst'
    epsilon^2 = .80724901
    
    . * Now use -estat esize-
    . estat esize, omega
    
    Effect sizes for linear models
    
    -------------------------------------------------------------------
                 Source | Omega-Squared     df     [95% Conf. Interval]
    --------------------+----------------------------------------------
                  Model |    .807249         3     .6175495    .8622965
                        |
                      b |    .807249         3     .6175495    .8622965
    -------------------------------------------------------------------
    
    .
    . * Compare with result from Phil Ender's -omega2- program
    . * package name:  omega2.pkg
    . *   To install:  net install omega2.pkg
    . omega2
    
    
     omega squared for b = 0.8023
     fhat effect size   = 2.0142
    
    .
    . * CONCLUSIONS:  
    . * 1. The result from -estat esize- matches my computation of eta^2.
    . * 2. The result from -estat esize, omega- matches my computation of epsilon^2.
    . * 3. The result from Phil Ender's omega2 matches my computation of omega^2.
    .
    . * REFERENCES
    . * https://www.statalist.org/forums/forum/general-stata-discussion/general/1364356-effect-sizes
    > -with-blank-or-zero-confidence-intervals?p=1364816#post1364816
    . * http://daniellakens.blogspot.ca/2015/06/why-you-should-use-omega-squared.html
    .
    end of do-file
    Code:
    . do "C:\bw\Stata\DO files\ANOVA\Oneway_RM_ANOVA_etaSq_Bug.do"
    
    . * Date:  15-Jun-2017
    . * File:  Oneway_RM_ANOVA_etaSq_Bug.DO
    . * Author:  Bruce Weaver, [email protected]
    . * Stata version:  Stata/IC v15 (Windows, 64-bit)
    .
    . * Q. Is -estat esize- after one-factor repeated measures ANOVA
    . *    computing eta-squared correctly?
    .
    . * Use data from this example:
    . * http://core.ecu.edu/psyc/wuenschk/MV/RM-ANOVA/RM1_Eta-Squared.pdf
    .
    . clear
    
    . input score1-score5
    
            score1     score2     score3     score4     score5
      1. 21 22  8  6  6
      2. 20 19 10  4  4
      3. 17 15  5  4  5
      4. 25 30 13 12 17
      5. 30 27 13  8  6
      6. 19 27  8  7  4
      7. 26 16  5  2  5
      8. 17 18  8  1  5
      9. 26 24 14  8  9
     10. end
    
    . * Reshape data from wide to long for use with -anova- command
    . generate id = _n
    
    . reshape long score, i(id) j(week)
    (note: j = 1 2 3 4 5)
    
    Data                               wide   ->   long
    -----------------------------------------------------------------------------
    Number of obs.                        9   ->      45
    Number of variables                   6   ->       3
    j variable (5 values)                     ->   week
    xij variables:
                   score1 score2 ... score5   ->   score
    -----------------------------------------------------------------------------
    
    . * Perform one-way RM ANOVA
    . anova score id week, repeated(week)
    
                             Number of obs =         45    R-squared     =  0.9272
                             Root MSE      =    2.68328    Adj R-squared =  0.8999
    
                      Source | Partial SS         df         MS        F    Prob>F
                  -----------+----------------------------------------------------
                       Model |  2935.9111         12   244.65926     33.98  0.0000
                             |
                          id |  486.71111          8   60.838889      8.45  0.0000
                        week |     2449.2          4       612.3     85.04  0.0000
                             |
                    Residual |      230.4         32         7.2  
                  -----------+----------------------------------------------------
                       Total |  3166.3111         44   71.961616  
    
    
    Between-subjects error term:  id
                         Levels:  9         (8 df)
         Lowest b.s.e. variable:  id
    
    Repeated variable: week
                                              Huynh-Feldt epsilon        =  1.0756
                                              *Huynh-Feldt epsilon reset to 1.0000
                                              Greenhouse-Geisser epsilon =  0.6845
                                              Box's conservative epsilon =  0.2500
    
                                                ------------ Prob > F ------------
                      Source |     df      F    Regular    H-F      G-G      Box
                  -----------+----------------------------------------------------
                        week |      4    85.04   0.0000   0.0000   0.0000   0.0000
                    Residual |     32
                  ----------------------------------------------------------------
    
    . *ereturn list
    . * ------------------------------------------
    . * My computations of eta^2 and partial eta^2
    . * ------------------------------------------
    . display " SS_week = " e(ss_2)
     SS_week = 2449.2
    
    . display "SS_error = " e(rss)
    SS_error = 230.4
    
    . display "   SS_id = " e(ss_1)
       SS_id = 486.71111
    
    . display e(ss_2)/(e(ss_2)+e(rss)) "  Partial eta^2 for Week"
    .91401702  Partial eta^2 for Week
    
    . display e(ss_2)/(e(ss_2)+e(rss)+e(ss_1)) "  Eta^2 for Week"
    .77351843  Eta^2 for Week
    
    . * -------------------------------------
    . * Stata's computation via -estat esize-
    . * -------------------------------------
    . estat esize
    
    Effect sizes for linear models
    
    -------------------------------------------------------------------
                 Source |   Eta-Squared     df     [95% Conf. Interval]
    --------------------+----------------------------------------------
                  Model |   .9272339        12     .8237562    .9340545
                        |
                     id |   .6787109         8       .35672     .734409
                   week |    .914017         4     .8292137    .9359729
    -------------------------------------------------------------------
    
    .
    . * CONCLUSION:  
    . * Following one-way RM ANOVA, -estat esize- computes
    . * partial eta^2, but reports it as eta^2.
    .
    .
    end of do-file
    .
    Finally, here is the code (without output), in case anyone wants it.

    Code:
    * Date:  15-Jun-2017
    * File:  Oneway_ANOVA_omegaSq_test.DO
    * Author:  Bruce Weaver, [email protected]
    * Stata version used:  Stata/IC v15 (Windows, 64-bit)
    
    * Q. Following one-way ANOVA, does -estat esize, omega-
    *    actually compute epsilon^2?
    
    clear
    use https://stats.idre.ucla.edu/stat/stata/faq/crf24
    *https://stats.idre.ucla.edu/stata/faq/
    anova y b
    *ereturn list
    * Hand calculation of eta^2:
    display "eta^2 = " e(ss_1)/(e(ss_1)+e(rss))
    estat esize // eta^2 computed by Stata
    * Hand calculations of omega^2 & epsilon^2:
    local sst = e(mss)+e(rss) // SS_total = SS_model + SS_residual
    local msr = e(rss)/e(df_r) // MS_residual
    display "  omega^2 = " (e(ss_1)-e(df_1)*`msr')/(`sst'+`msr')
    display "epsilon^2 = " (e(ss_1)-e(df_1)*`msr')/`sst'
    * Now use -estat esize-
    estat esize, omega
    
    * Compare with result from Phil Ender's -omega2- program
    * package name:  omega2.pkg
    *   To install:  net install omega2.pkg
    omega2
    
    * CONCLUSIONS:  
    * 1. The result from -estat esize- matches my computation of eta^2.
    * 2. The result from -estat esize, omega- matches my computation of epsilon^2.
    * 3. The result from Phil Ender's omega2 matches my computation of omega^2.
    
    * REFERENCES
    * https://www.statalist.org/forums/forum/general-stata-discussion/general/1364356-effect-sizes-with-blank-or-zero-confidence-intervals?p=1364816#post1364816
    * http://daniellakens.blogspot.ca/2015/06/why-you-should-use-omega-squared.html

    Code:
    * Date:  15-Jun-2017
    * File:  Oneway_RM_ANOVA_etaSq_Bug.DO
    * Author:  Bruce Weaver, [email protected]
    * Stata version:  Stata/IC v15 (Windows, 64-bit)
    
    * Q. Is -estat esize- after one-factor repeated measures ANOVA
    *    computing eta-squared correctly?
    
    * Use data from this example:
    * http://core.ecu.edu/psyc/wuenschk/MV/RM-ANOVA/RM1_Eta-Squared.pdf
    
    clear
    input score1-score5
    21 22  8  6  6
    20 19 10  4  4
    17 15  5  4  5
    25 30 13 12 17
    30 27 13  8  6
    19 27  8  7  4
    26 16  5  2  5
    17 18  8  1  5
    26 24 14  8  9
    end
    * Reshape data from wide to long for use with -anova- command
    generate id = _n
    reshape long score, i(id) j(week)
    * Perform one-way RM ANOVA
    anova score id week, repeated(week)
    *ereturn list
    * ------------------------------------------
    * My computations of eta^2 and partial eta^2
    * ------------------------------------------
    display " SS_week = " e(ss_2)
    display "SS_error = " e(rss)
    display "   SS_id = " e(ss_1)
    display e(ss_2)/(e(ss_2)+e(rss)) "  Partial eta^2 for Week"
    display e(ss_2)/(e(ss_2)+e(rss)+e(ss_1)) "  Eta^2 for Week"
    * -------------------------------------
    * Stata's computation via -estat esize-
    * -------------------------------------
    estat esize
    
    * CONCLUSION:  
    * Following one-way RM ANOVA, -estat esize- computes
    * partial eta^2, but reports it as eta^2.


    --
    Bruce Weaver
    Email: [email protected]
    Version: Stata/MP 18.5 (Windows)

  • #2
    Update: Thanks to Chuck Huber & team, the 06nov2017 update for Stata 15 has fixed some of the issues identified in #1. Specifically, estat esize following one-way ANOVA now computes eta2, omega2 and epsilon2 correctly.

    However, the results for the second example in #1 are unchanged: estat esize following one-way repeated measures ANOVA still computes partial eta2, but labels it eta2.

    Here is an updated version of the code & output for example 1 in #1 (one-way ANOVA followed by estat esize).

    Code:
    . * To work properly, this code requires Stata 15 with the 06nov2017 update.
    .
    . clear
    
    . use https://stats.idre.ucla.edu/stat/stata/faq/crf24
    (CRF Example - Kirk, 1st Edition)
    
    . *https://stats.idre.ucla.edu/stata/faq/
    . anova y b
    
                             Number of obs =         32    R-squared     =  0.8259
                             Root MSE      =    1.21008    Adj R-squared =  0.8072
    
                      Source | Partial SS         df         MS        F    Prob>F
                  -----------+----------------------------------------------------
                       Model |      194.5          3   64.833333     44.28  0.0000
                             |
                           b |      194.5          3   64.833333     44.28  0.0000
                             |
                    Residual |         41         28   1.4642857  
                  -----------+----------------------------------------------------
                       Total |      235.5         31   7.5967742  
    
    . *ereturn list
    . * Hand calculation of eta^2:
    . display "eta^2 = " e(ss_1)/(e(ss_1)+e(rss))
    eta^2 = .82590234
    
    . estat esize // eta^2 computed by Stata
    
    Effect sizes for linear models
    
    -----------------------------------------------------------------
                 Source | Eta-Squared     df     [95% Conf. Interval]
    --------------------+--------------------------------------------
                  Model |   .8259023       3     .6545609    .8756227
                        |
                      b |   .8259023       3     .6545609    .8756227
    -----------------------------------------------------------------
    
    .
    . * Hand calculations of omega^2 & epsilon^2:
    . local sst = e(mss)+e(rss) // SS_total = SS_model + SS_residual
    
    . local msr = e(rss)/e(df_r) // MS_residual
    
    . display "  omega^2 = " (e(ss_1)-e(df_1)*`msr')/(`sst'+`msr')
      omega^2 = .80226074
    
    . estat esize, omega // Compute omega-squared via -esize-
    
    Effect sizes for linear models
    
    -------------------------------------------
                 Source | Omega-Squared      df
    --------------------+----------------------
                  Model |    .8022607         3
                        |
                      b |    .8022607         3
    -------------------------------------------
    
    . display "epsilon^2 = " (e(ss_1)-e(df_1)*`msr')/`sst'
    epsilon^2 = .80724901
    
    . * Now use -estat esize-
    . estat esize, epsilon // Compute epsilon-squared via -esize-
    
    Effect sizes for linear models
    
    ---------------------------------------------
                 Source | Epsilon-Squared      df
    --------------------+------------------------
                  Model |      .807249          3
                        |
                      b |      .807249          3
    ---------------------------------------------
    
    .
    . * CONCLUSION:
    . * With the update of 06-Nov-2017 installed, -estat esize- following
    . * -anova- is computing eta^2, omega^2 & epsilon^2 correctly.
    Cheers,
    Bruce
    --
    Bruce Weaver
    Email: [email protected]
    Version: Stata/MP 18.5 (Windows)

    Comment


    • #3
      Mea culpa in #2. Regarding the use of estat esize following one-way repeated measures ANOVA, Stata is still computing the same effect size measure it did before (partial eta2). The table still has Eta-Squared as the column heading; but a note below the table clarifies that it is a partial eta2. Thanks to Chuck Huber (StataCorp) for helping me see what I should have seen in the first place.

      Here is the output from example 2 in post #1 of this thread (using Stata 15 with the 06nov2017 update installed):

      Code:
      . * -------------------------------------
      . * Stata's computation via -estat esize-
      . * -------------------------------------
      . estat esize
      
      Effect sizes for linear models
      
      -----------------------------------------------------------------
                   Source | Eta-Squared     df     [95% Conf. Interval]
      --------------------+--------------------------------------------
                    Model |   .9272339      12     .8237562    .9340545
                          |
                       id |   .6787109       8       .35672     .734409
                     week |    .914017       4     .8292137    .9359729
      -----------------------------------------------------------------
      Note: Eta-Squared values for individual model terms are partial.
      --
      Bruce Weaver
      Email: [email protected]
      Version: Stata/MP 18.5 (Windows)

      Comment

      Working...
      X