Announcement

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

  • rangestat for (cumulative) rolling standard deviations

    Dear All, The following question comes from http://bbs.pinggu.org/thread-6298239-1-1.html.
    The end is to obtain, for each `group_id', the standard deviation of `var1' from the very first observation till the current observation (in the order of `order').
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(group_id var1 var2 order)
    1 2 3  1
    1 4 2  2
    1 4 5  3
    1 3 1  4
    1 2 2  5
    2 2 3  1
    2 4 2  2
    2 4 5  3
    2 3 1  4
    2 2 2  5
    2 2 3  6
    2 4 2  7
    2 4 5  8
    2 3 1  9
    2 2 2 10
    end
    Any suggestion is highly appreciated.
    Ho-Chuan (River) Huang
    Stata 19.0, MP(4)

  • #2
    Code:
    rangestat (sd) var1, interval(order . 0) by(group_id)

    Comment


    • #3
      Dear Robert, Many thanks. As I expected, it should be relatively easy for -rangestat- command to do the task. However, I always have trouble in understanding how to use -interval( )- option in some cases.

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

      Comment

      Working...
      X