Announcement

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

  • MVSUMM rolling medians

    I am trying to calculate rolling medians of stock returns every 3 days but i don't know how to use the mvsumm function. Any help would be greatly appreciated!

  • #2
    mvsumm is a command, not a function, and it can be installed from SSC. (Posters are asked to explain the provenance of user-written programs they refer to: see FAQ Advice #12.)

    I don't know what is proving difficult here as use of the median is a documented possibility.

    I would typically use tsegen now, also from SSC, which differs slightly in by default using the data to the maximum extent possible.

    Compare e.g.

    Code:
    webuse grunfeld
    
    mvsumm invest, stat(median) win(3) gen(inv3ymed) 
     
    tsegen inv3ymed2 = rowmedian(L(-1/1).invest)

    Comment


    • #3
      Thank for the response nick! Using the above code is giving me "variable date_5_min not found" error. I have no idea why STATA is referring to a variable called "date_5_min" as i have not mentioned it anywhere in the code

      Comment


      • #4
        Sorry, but there is nothing reproducible here in #3. You need to show any problem with the exact code you are using and a reproducible data example.

        Do swing by

        http://www.statalist.org/forums/help#stata (crucial)

        and

        http://www.statalist.org/forums/help#spelling (incidental).



        Comment


        • #5
          Sorry for not being clear earlier. I have a variable in my data called stock returns and in an attempt to generate a new variable "ret3med" which would show the rolling median of the past three returns, i used the following code:

          mvsumm returns , stat(median) win(3) gen(ret3ymed)

          This is giving me "variable date_5_min not found" error

          Hope that was clearer!

          Comment


          • #6
            It is clearer, but I can see nothing informative about your data.

            Did you read the FAQ Advice #12 as suggested?

            Note that, as documented, mvsumm requires tsset (or xtset) data; if for some bizarre reason your time variable has been removed or removed since that setting, it is unlikely to proceed.
            Last edited by Nick Cox; 21 Feb 2017, 12:53.

            Comment

            Working...
            X