Announcement

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

  • Confidence Intervals on the Means from a 1-way ANOVA Analysis

    If I am completing a 1-way ANOVA (command: oneway outcomevariable independentvariable) and am looking to obtain confidence intervals for the means, how do I go about this?

  • #2
    Al:
    welcome to this forum.
    You may want to try:
    Code:
    use "C:\Program Files (x86)\Stata15\ado\base\a\auto.dta"
    . oneway price foreign, tabulate
    
                |          Summary of Price
       Car type |        Mean   Std. Dev.       Freq.
    ------------+------------------------------------
       Domestic |   6,072.423   3,097.104          52
        Foreign |   6,384.682   2,621.915          22
    ------------+------------------------------------
          Total |   6,165.257   2,949.496          74
    
                            Analysis of Variance
        Source              SS         df      MS            F     Prob > F
    ------------------------------------------------------------------------
    Between groups      1507382.66      1   1507382.66      0.17     0.6802
     Within groups       633558013     72   8799416.85
    ------------------------------------------------------------------------
        Total            635065396     73   8699525.97
    
    Bartlett's test for equal variances:  chi2(1) =   0.7719  Prob>chi2 = 0.380
    
    . mean price
    
    Mean estimation                   Number of obs   =         74
    
    --------------------------------------------------------------
                 |       Mean   Std. Err.     [95% Conf. Interval]
    -------------+------------------------------------------------
           price |   6165.257   342.8719      5481.914      6848.6
    --------------------------------------------------------------
    .
    As an aside, why not switching to -regress- which is far more flexible than -oneway-?
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Carlo has given good advice to obtain the confidence interval for the marginal mean (ignoring means within classes of foreign, in his example). Using -mean- is disconnected from the -oneway- procedure (that is, it will work without previous estimation commands).

      If you had wanted to obtain model-estimated means at each level of a factor variable, you can do the following.

      Code:
      * continue with the auto example by Carlo
      sysuse auto
      
      regress price i.foreign
            Source |       SS           df       MS      Number of obs   =        74
      -------------+----------------------------------   F(1, 72)        =      0.17
             Model |  1507382.66         1  1507382.66   Prob > F        =    0.6802
          Residual |   633558013        72  8799416.85   R-squared       =    0.0024
      -------------+----------------------------------   Adj R-squared   =   -0.0115
             Total |   635065396        73  8699525.97   Root MSE        =    2966.4
      
      ------------------------------------------------------------------------------
             price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
           foreign |
          Foreign  |   312.2587   754.4488     0.41   0.680    -1191.708    1816.225
             _cons |   6072.423    411.363    14.76   0.000     5252.386     6892.46
      ------------------------------------------------------------------------------
      This model implies that the estimates mean and CI for domestic cards is about $6072 [5252, 6892]. The corresponding mean for foreign can be obtained using -lincom-.

      Code:
      lincom _b[_cons]+_b[1.foreign]
      
       ( 1)  1.foreign + _cons = 0
      
      ------------------------------------------------------------------------------
             price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
               (1) |   6384.682   632.4346    10.10   0.000     5123.947    7645.417
      ------------------------------------------------------------------------------
      Or this can more easily be done in one call to -margins-.

      Code:
      . margins i.foreign
      
      Adjusted predictions                            Number of obs     =         74
      Model VCE    : OLS
      
      Expression   : Linear prediction, predict()
      
      ------------------------------------------------------------------------------
                   |            Delta-method
                   |     Margin   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
           foreign |
         Domestic  |   6072.423    411.363    14.76   0.000     5252.386     6892.46
          Foreign  |   6384.682   632.4346    10.10   0.000     5123.947    7645.417
      ------------------------------------------------------------------------------

      Comment


      • #4
        Continuing Leonardo's nice examples in #3, here is yet another way.

        Code:
        . regress price ibn.foreign, noconstant noheader
        ------------------------------------------------------------------------------
               price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
             foreign |
           Domestic  |   6072.423    411.363   14.762   0.0000     5252.386    6892.460
            Foreign  |   6384.682    632.435   10.095   0.0000     5123.947    7645.417
        ------------------------------------------------------------------------------
        
        . // ibn. = no base level
        . // noconstant = no constant in the model
        --
        Bruce Weaver
        Email: [email protected]
        Version: Stata/MP 18.5 (Windows)

        Comment


        • #5
          Originally posted by al morton View Post
          If I am completing a 1-way ANOVA (command: oneway outcomevariable independentvariable) and am looking to obtain confidence intervals for the means, how do I go about this?
          It seems a non sequitur—you don't need to perform ANOVA to get the CI for the mean response at each level of a grouping variable
          Code:
          sysuse auto
          statsby , by(rep78): ci means price
          list, noobs separator(0)
          and individual groups' independent CIs of the mean response aren't what ANOVA is all about, aren't pertinent to it; and viewing them doesn't elucidate anything about the ANOVA you just completed.


          Did you mean confidence intervals for differences between the means?
          Code:
          sysuse auto
          anova price rep78
          contrast r.rep78, mcompare(bonferroni) cieffects nowald

          Comment

          Working...
          X