Announcement

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

  • Volatility calculation

    Hi,

    I have data on daily stock prices for -240 through -40 days prior the issue date form crsp. I am trying to calculate daily stock return volatility for each firm for each issue date. I have calculated the daily returns form the prices but can't find a command that would calculate daily stock return volatility for each firm for each issue date. I also tried using the following I found in one of the forums as suggested by Clyde Schechter but the volatility column has all values missing. Can any one please help?

    format date1 %d
    xtset permno date
    // CALCULATE SOME RUNNING TOTALS OF RET AND RET^2
    by permno (date1), sort: gen sum_ret = sum(ret)
    by permno (date1): gen sum_ret_sq = sum(ret^2)
    // AND A RUNNING COUNT OF NON MISSING OBSERVATIONS
    by permno (date1): gen int n_obs = sum(!missing(ret))

    // NOW CALCULATE RUNNING STANDARD DEVIATIONS
    gen variance = (L1.sum_ret_sq - L18.sum_ret_sq)/(L1.n_obs-L18.n_obs) /// - ((L1.sum_ret - L18.sum_ret)/(L1.n_obs-L18.n_obs))^2


    My data looks like as follows:
    permco price date
    10104 15.98 25-Nov-08
    10104 16.14 26-Nov-08
    10104 16.09 28-Nov-08
    10104 15.47 1-Dec-08
    10104 15.79 2-Dec-08
    10104 16.13 3-Dec-08
    10104 15.44 4-Dec-08
    10104 16.32 5-Dec-08
    10104 17.04 8-Dec-08
    10104 16.94 9-Dec-08
    10104 17.39 10-Dec-08
    10104 16.46 11-Dec-08
    10104 16.84 12-Dec-08
    10104 16.45 15-Dec-08
    10104 17.27 16-Dec-08
    10104 16.74 17-Dec-08
    10104 16.61 18-Dec-08
    10104 17.78 19-Dec-08







  • #2
    Answered here.

    Comment

    Working...
    X