Announcement

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

  • calculating spillover

    I am trying to calculate spillover that is computed as the sum of the differences in knowledge between focal firm i and rival firm j for all firms in the same industry with more knowledge (R&D) than the focal firm:

    𝑆𝑖𝑡 = Σ𝑗≠𝑖 𝑅𝑗𝑡 − 𝑅𝑖𝑡 ∀ 𝑅𝑗𝑡 ≥ 𝑅𝑖𝑡

    I am not new to stata, but not sure how to do this calculation? Any help is much appreciated.

    I searched the forum and didn't see anything like this.

    Thanks for your consideration.



  • #2
    Such problems are very often discussed here, perhaps once a week.

    For example, see this very recent thread from last week:

    http://www.statalist.org/forums/foru...al-group-means

    and more generally search for mentions of rangestat (SSC).

    You give no data example or variable names but consider this example:

    Code:
    webuse grunfeld, clear
    rangestat (sum) mvalue (count) mvalue, by(year) interval(mvalue 0 1e9) excludeself
    gen spillover = mvalue_sum - mvalue_count * mvalue


    We calculate the total of other values at least as big as the value in focus, and then subtract a correction term.

    In your problem, 1e9 may be too small but I doubt it. It is just an arbitrarily large number to include any maximum in the data.

    Also, it sounds as if your
    by() option should include an industry identifier, say by(industry year)

    Although rangestat is a wonderful command (full disclosure: I am a junior author), there is a direct solution too. Once we sort values into order then we just want to work with values greater. Strictly this method needs adjustment for ties but there aren't any with this example.

    Code:
    gsort year -mvalue
    by year: gen mvalue_SUM = sum(mvalue[_n-1])
    by year: gen spillover2 = mvalue_SUM - mvalue * (_n - 1)



    Comment


    • #3
      Nick,

      Thank you very much for the help. I had never heard of rangestat before. Seems to be a great command.

      Comment

      Working...
      X