Announcement

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

  • Converting daily stock returns data to weekly data and monthly data

    I have panel data with gaps of daily stock returns. I want to convert daily stock returns data to weekly and montly returns data.

    I have used user written program:
    Code:
    ascol return, toweek return
    This converts the data but changes dates to weeks identifier. And also erases other data like company symbol. Same goes to the months function.

    Is there a way to do so keeping in mind that returns should be adjust to its repective time interval ? I also want my other data like symbol to not be erased.

    Code:
        +------------------------------------------+
        symbol                date   return   ID
        ------------------------------------------
    1.    ABOT     January 4, 2000        0    1
    2.    ABOT     January 6, 2000        0    1
    3.    ABOT    January 12, 2000        0    1
    4.    ABOT    January 13, 2000        0    1
    5.    ABOT    January 14, 2000    .0448    1
        ------------------------------------------
    6.    ABOT    January 17, 2000        0    1
    7.    ABOT    January 18, 2000        0    1
    8.    ABOT    January 19, 2000        0    1
    9.    ABOT    January 20, 2000        0    1
    10.    ABOT    January 21, 2000        0    1
        ------------------------------------------
    11.    ABOT    January 24, 2000     .001    1
    12.    ABOT    January 25, 2000    .0466    1
    13.    ABOT    January 26, 2000        0    1
    14.    ABOT    January 27, 2000    .0545    1
    15.    ABOT    January 28, 2000        0    1
        ------------------------------------------
    16.    ABOT    January 31, 2000        0    1
    17.    ABOT    February 1, 2000   -.0345    1
    18.    ABOT    February 2, 2000        0    1
    19.    ABOT    February 3, 2000    .0357    1
    20.    ABOT    February 4, 2000    .0345    1
        ------------------------------------------
    21.    ABOT    February 7, 2000        0    1
    22.    ABOT    February 8, 2000   -.0083    1
    23.    ABOT    February 9, 2000        0    1
    24.    ABOT   February 10, 2000        0    1
    25.    ABOT   February 11, 2000        0    1
        +------------------------------------------+
    .



    Last edited by Subhan Ahmad; 11 Jul 2016, 01:48.

  • #2
    -ascol- is not a part of official Stata; it is a user-written command. It is generally helpful when discussing user-written commands to indicate where they come from.

    In any case, just looking at the description shown by looking at -find ascol-, it relies on -collapse-, so it will destroy any variables other than the ones it is specifically working with. But the solution to your problem is simple: just -merge- the -ascol- results back in with your original data. If you are not familiar with the -merge- command, now is the time to learn it. The manual section is very clear with lots of examples. The time you spend learning it will be amply repaid; -merge- is "bread and butter" Stata.

    Comment


    • #3
      If you have original price data, you may want to collapse the data by month or week before you do the return calculations. Often, instead of collapsing, people want the price at the start or end of the period. If you have missing data in the price series, you may want to interpolate or something to fill in the series and then keep the first or last days. The mean of the daily returns is not necessarily the monthly return.

      Comment


      • #4
        Clyde Schechter , Thank You, I followed your suggestion and it worked.

        Comment

        Working...
        X