Announcement

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

  • Geomean Standard Deviation

    Good morning,

    Please refer to my data post.
    Is is possible to create a new variable with the geomean standard deviation of the dslr variable?

    Thank you,
    Hans

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int dslr float(avgracedslr stdevracedslr geomeanracedslr) byte geomeanstdev
      36 249.3333 556.9398 40.3126 .
      14 249.3333 556.9398 40.3126 .
      16 249.3333 556.9398 40.3126 .
    1386 249.3333 556.9398 40.3126 .
      32 249.3333 556.9398 40.3126 .
      12 249.3333 556.9398 40.3126 .
    end

  • #2
    The recipe for geometric standard deviation -- which may be (related to) what you want -- I take to be exp(SD(ln()).

    With your data example (thanks), I get this:

    Code:
    . gen work = ln(dslr)
    
    . su work 
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
            work |          6    3.696664    1.790024   2.484907   7.234177
    
    . di exp(r(sd))
    5.9895968
    
    . 
    . egen geosd = sd(ln(dslr))
    
    . replace geosd = exp(geosd)
    (6 real changes made)
    
    . 
    . list avg-geosd in 1 
    
         +-----------------------------------------------------------------+
         | avgrac~r   stdevr~r   geomea~r   geomea~v       work      geosd |
         |-----------------------------------------------------------------|
      1. | 249.3333   556.9398    40.3126          .   3.583519   5.989597 |
         +-----------------------------------------------------------------+
    Using egen extends more easily to wanting a separate result for each of several blocks of observations.

    Comment


    • #3
      Thanks very much, Nick.

      Comment

      Working...
      X