Announcement

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

  • ANOVA unequal variances

    Hi, I want to compare a score across 5 groups where sample sizes (all of them N<30) are very unequal. Using KW would be wrong? Is there an option for unequal variances for ANOVA in stata?
    Thank you

  • #2
    Your post's title says "unequal variances". Your post's body says "sample sizes . . . unequal". Which is it?

    Comment


    • #3
      Both sample size and variances are unequal. Sorry for the writing!

      Comment


      • #4
        For suggestions see
        https://www.stata.com/statalist/arch.../msg00232.html
        https://www.statalist.org/forums/for...-bartlett-test
        Best wishes

        (Stata 16.1 MP)

        Comment


        • #5
          I believe the issue underlying ana ac 's post is that the greater the variability in the group sizes, the less robust ANOVA is to heterogeneity of variance. If this was an SPSS forum, I would suggest using the ONEWAY command and selecting either the WELCH or BROWN-FORSYTHE option on the STATISTICS sub-command. It remains a mystery to me why one or both of those options have not been added to either -oneway- or -anova-. YMMV.

          Earlier this summer, I wrote some rough & ready code to calulate Welch's F for a one-way ANOVA problem with 3 groups. I've pasted it below in case you find it helpful.

          Cheers,
          Bruce


          Code:
          // Date:  15-Jun-2021
          // Use equations shown in Andy Field's document to compute
          // Welch's F-test.
          // https://www.discoveringstatistics.com/docs/welchf.pdf
          // The data AF uses come from this document:
          // https://www.discoveringstatistics.com/repository/contrasts.pdf
          
          clear
          input byte group y
          1 3  
          1 2  
          1 1  
          1 1  
          1 4
          2 5  
          2 2  
          2 4  
          2 2  
          2 3
          3 7  
          3 4  
          3 5  
          3 3  
          3 6
          end
          
          preserve
          drop if missing(group)
          statsby Ybar=r(mean) Var=r(Var) n=r(N), by(group) clear:  summarize y
          list
          quietly {
          generate double  Wt        = n/Var
          generate double  WtMean    = Wt*Ybar
          egen     double  SumWt     = total(Wt)
          egen     double  SumWtMean = total(WtMean)
          generate double  WelchGM   = SumWtMean/SumWt
          generate double  WtSqDev   = Wt*(Ybar-WelchGM)^2
          egen     double  SSmodel   = total(WtSqDev)
          generate byte    k         = _N // # of groups   
          generate double  MSmodel   = SSmodel/(k-1)
          generate double  Lterm     = (1-Wt/SumWt)^2 / (n-1)
          egen     double  lambda    = total(Lterm)
          replace          lambda    = lambda*3/(k^2-1)
          generate double  MSerror   = 1+2*lambda*(k-2)/3
          generate double  WelchF    = MSmodel/MSerror
          generate byte    df1       = k-1
          generate double  df2       = 1/lambda
          generate double  p         = Ftail(df1,df2,WelchF)
          }
          list WelchF-p in 1
          display               _newline ///
          "From SPSS ONEWAY:"   _newline ///
          "Welch F = "4.320451  _newline ///
          "    df1 = " 2              _newline ///
          "    df2 = " 7.943375     _newline ///    
          "      p = " .053738
          
          restore
          
          // Date:  17-Aug-2021
          // Compare Welch's F-test to multilevel modeling approach
          // in post #3 here:
          // https://www.statalist.org/forums/forum/general-stata-discussion/general/1427959-anova-rejection-of-bartlett-test
          // Note that I have added the dfmethod(anova) option.
          
          mixed y i.group, ml residuals(independent, by(group)) ///
          nolrtest nolog dfmethod(anova)
          
          margins group
          margins group, pwcompare(effects) mcompare(noadjust)
          
          // Compare to -regress- with vce(robust)
          regress y i.group, vce(robust)
          --
          Bruce Weaver
          Email: [email protected]
          Version: Stata/MP 18.5 (Windows)

          Comment

          Working...
          X