Announcement

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

  • row means different?

    s
    Ho-Chuan (River) Huang
    Stata 19.0, MP(4)

  • #2
    Dear All, I ran the following code.
    Code:
    webuse grunfeld, clear
    
    gen m0 = (invest+mvalue+kstock)/3
    egen m1 = mean(invest+mvalue+kstock)
    egen m2 = rowmean(invest mvalue kstock)
    egen m3 = rowmean(invest-kstock)
    with results
    Code:
     list m0-m3 in 1/10, sep(0)
    
         +-------------------------------------------+
         |       m0         m1         m2         m3 |
         |-------------------------------------------|
      1. | 1132.967   1503.656   1132.967   1132.967 |
      2. | 1702.033   1503.656   1702.033   1702.033 |
      3. | 1984.867   1503.656   1984.867   1984.867 |
      4. | 1086.367   1503.656   1086.367   1086.367 |
      5. |   1615.8   1503.656     1615.8     1615.8 |
      6. | 1770.767   1503.656   1770.767   1770.767 |
      7. |   1772.8   1503.656     1772.8     1772.8 |
      8. | 1331.933   1503.656   1331.933   1331.933 |
      9. |   1605.8   1503.656     1605.8     1605.8 |
     10. | 1709.467   1503.656   1709.467   1709.467 |
         +-------------------------------------------+
    My question is that: what is `m1' different from `m0', `m2', and `m3'? Thanks.
    Ho-Chuan (River) Huang
    Stata 19.0, MP(4)

    Comment


    • #3
      m0, m2, and m3 are all the same, that is an average for each row. m1 first adds the three variable by row and then finds mean of that summed column, hence it is constant.

      Code:
      gen m1a = invest+mvalue+kstock
      
      sum m1a
      
          Variable |        Obs        Mean    Std. Dev.       Min        Max
      -------------+---------------------------------------------------------
               m1a |        200    1503.656    1681.516      65.27     9323.4
      
      .
      Regards
      --------------------------------------------------
      Attaullah Shah, PhD.
      Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
      FinTechProfessor.com
      https://asdocx.com
      Check out my asdoc program, which sends outputs to MS Word.
      For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

      Comment


      • #4
        Dear Attaullah, Got it and thanks.
        Ho-Chuan (River) Huang
        Stata 19.0, MP(4)

        Comment

        Working...
        X