Announcement

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

  • Mean with SE

    Hi,
    V1 is outcome. First code below gives me 'mean with std. error (SE)' for each group.
    Does the second code take clustering into account and return correct SE for each group?

    Code:
    mixed V1 [pweight=weight] || GroupingVariable: , pwscale(size) variance ml
    Code:
    mean V1 [pweight=weight], over(GroupingVariable)
    Last edited by Nanco Bonnevieri; 01 Aug 2023, 02:06.

  • #2
    Nanco:
    I think you should use the -vce(cluster clusterid)-option:
    Code:
    . sysuse auto.dta
    (1978 automobile data)
    
    . mean price, over(foreign)
    
    Mean estimation                                Number of obs = 74
    
    -----------------------------------------------------------------
                    |       Mean   Std. err.     [95% conf. interval]
    ----------------+------------------------------------------------
    c.price@foreign |
          Domestic  |   6072.423   429.4911      5216.449    6928.398
           Foreign  |   6384.682   558.9942      5270.608    7498.756
    -----------------------------------------------------------------
    
    
    . mean price, vce(cluster foreign) over(foreign)
    
    Mean estimation                                Number of obs = 74
    
                       (Std. err. adjusted for 2 clusters in foreign)
    -----------------------------------------------------------------
                    |               Robust
                    |       Mean   std. err.     [95% conf. interval]
    ----------------+------------------------------------------------
    c.price@foreign |
          Domestic  |   6072.423   2.13e-14      6072.423    6072.423
           Foreign  |   6384.682   2.84e-14      6384.682    6384.682
    -----------------------------------------------------------------
    
    . mean price [pweight= turn], over(foreign)
    
    Mean estimation                                Number of obs = 74
    
    -----------------------------------------------------------------
                    |       Mean   Std. err.     [95% conf. interval]
    ----------------+------------------------------------------------
    c.price@foreign |
          Domestic  |   6198.785     450.76      5300.422    7097.149
           Foreign  |    6448.99   564.4797      5323.983    7573.996
    -----------------------------------------------------------------
    
    .
    In addition, invoking the -vce(cluster clusterid)- option with less than 30 clusters gives back totally unreliable standard errors.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment

    Working...
    X