Announcement

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

  • ANOVA standard deviations

    Hi,

    I was wondering if there is any way to output weighted standard deviations for ANOVAs in stata?
    For example:

    Code:
    webuse manuf
    anova yield method c.temperature
    I can output the weighted means for yield by method using
    Code:
    margins method
    But I dont know how to output the weighted means?

    Additionally if I was not controlling for temperature I could use:
    Code:
    oneway yield method, tabulate
    to get the weighted standard deviations

    Is there another command that could do this for ANOVAs that control for another variable (in this case c.temperature)?


    Thank you very much for any help!

  • #2
    Wendy:
    is what follows that you're looking for?
    Code:
    . webuse manuf
    . anova yield method c.temperature
    
                             Number of obs =         36    R-squared     =  0.1980
                             Root MSE      =    2.98544    Adj R-squared =  0.1494
    
                      Source | Partial SS         df         MS        F    Prob>F
                 ------------+----------------------------------------------------
                       Model |     72.625          2     36.3125      4.07  0.0262
                             |
                      method |      42.25          1       42.25      4.74  0.0367
                 temperature |     30.375          1      30.375      3.41  0.0739
                             |
                    Residual |    294.125         33   8.9128788  
                 ------------+----------------------------------------------------
                       Total |     366.75         35   10.478571  
    
    . margins method
    
    Predictive margins                                          Number of obs = 36
    
    Expression: Linear prediction, predict()
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
          method |
           Stir  |        6.5    .703676     9.24   0.000      5.06836     7.93164
           Fold  |   8.666667    .703676    12.32   0.000     7.235027    10.09831
    ------------------------------------------------------------------------------
    
    . bysort method: sum yield
    
    ------------------------------------------------------------------------------------------------------------------------------------------
    -> method = Stir
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
           yield |         18         6.5    2.995094          2         13
    
    ------------------------------------------------------------------------------------------------------------------------------------------
    -> method = Fold
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
           yield |         18    8.666667    3.180825          3         14
    
    
    .
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      No unfortunately. As far as I know the bysort command doesn't give adjusted means/standard deviations:

      Code:
      . webuse autom
      (1978 automobile data)
      
      . anova price foreign c.weight
      
                               Number of obs =         74    R-squared     =  0.4989
                               Root MSE      =    2117.02    Adj R-squared =  0.4848
      
                        Source | Partial SS         df         MS        F    Prob>F
                    -----------+----------------------------------------------------
                         Model |  3.169e+08          2   1.584e+08     35.35  0.0000
                               |
                       foreign |  1.326e+08          1   1.326e+08     29.59  0.0000
                        weight |  3.154e+08          1   3.154e+08     70.36  0.0000
                               |
                      Residual |  3.182e+08         71   4481776.4  
                    -----------+----------------------------------------------------
                         Total |  6.351e+08         73     8699526  
      
      . margins foreign
      
      Predictive margins                                          Number of obs = 74
      
      Expression: Linear prediction, predict()
      
      ------------------------------------------------------------------------------
                   |            Delta-method
                   |     Margin   std. err.      t    P>|t|     [95% conf. interval]
      -------------+----------------------------------------------------------------
           foreign |
         Domestic  |   5083.986   316.3435    16.07   0.000     4453.215    5714.757
          Foreign  |   8720.987   530.3685    16.44   0.000     7663.463    9778.512
      ------------------------------------------------------------------------------
      
      . bysort foreign: sum price
      
      ---------------------------------------------------------------------------------------------------------------------------------
      -> foreign = Domestic
      
          Variable |        Obs        Mean    Std. dev.       Min        Max
      -------------+---------------------------------------------------------
             price |         52    6072.423    3097.104       3291      15906
      
      ---------------------------------------------------------------------------------------------------------------------------------
      -> foreign = Foreign
      
          Variable |        Obs        Mean    Std. dev.       Min        Max
      -------------+---------------------------------------------------------
             price |         22    6384.682    2621.915       3748      12990

      Comment

      Working...
      X