Announcement

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

  • Rangestat: value weighted variance and skewness

    Dear Stata users

    I need to calculate equially- and value-weighted variance and skewness for each id/month.

    I am aware of rangestat equally-weighted code:

    Code:
    rangestat (sd) market_returns (skewness) market_returns, interval ( monthly_date . 0) by(id)
    gen variance_market_returns=market_returns_sd^2
    Is there any way to calculate value-weighted (by market_cap) variance and skewness using rangestat command?

    If not, what is the alternative way out?

    I am aware of collapse command which can adjust for weights but it does not have variance or skewness option.

    Code:
    collapse (sd) market_returns [weight=market_cap], by (id month)
    Any advice is highly appreciated.

    Thank you.
    Last edited by Olena Onishchenko; 20 Aug 2019, 01:38.

  • #2
    rangestat is from SSC as you are asked to explain (FAQ Advice #12). It doesn't support weights directly. You could write your own extra code to support weights, using that or rangerun (SSC).

    Skewness here evidently means the moment-based measure. I wouldn't trust skewness much for subsets of about 30, if that's your data. I fear nevertheless that this is the standard method in your field. I'd flag that (mean - median) / SD works quite well often and is bounded by [-1, 1].

    Comment


    • #3
      Nick

      Thank you.

      Can you advice how to write extra code to support weights using rangerun?
      Last edited by Olena Onishchenko; 20 Aug 2019, 21:10.

      Comment


      • #4
        I'd advise studying the help for examples. One example concerns skewness and one uses weights....

        Comment

        Working...
        X