Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: calculate volatility in different ways


From   Nadine R <[email protected]>
To   [email protected]
Subject   st: calculate volatility in different ways
Date   Mon, 25 Jul 2011 13:00:02 +0200

Dear Statalisters!

I have a new problem: I want to calculate the volatility of some stock
returns using Equally Weighted Moving Averages and Exponential
Weighted Moving Averages in Stata 11.0. I have daily return data for
the stocks. I did not use the standard deviation measures as I need
the volatilities for different periods (if I could calculate the
60-day-volatilities for 10 years with this formula I would do it like
this).

formula for Equally Weighted (for a 60-day-window: M=60):
variance at day t = 1/M * sum of the 60 preceding squared returns
variance at day 60 = 1/60 * Sum(from (return t=1)^2 to (return t=60)^2)
variance at day 61 = 1/60 * Sum(from (return t=2)^2 to (return t=61)^2)
...

I tried it with a formula like this:
generate var = 1/60 * sum((return[_n-60])^2 - (return[_n])^2)

where the "-" should indicate a "until/till" but Stata interpreted it
as a minus.

formula for the Exponential Weighted Moving Averages:
variance at day t = lambda*variance(t-1) + (1 - lambda)*squared return(t-1)

I tried it with a formula like this with lambda = 0.95 but it seems
that Stata does not calculate var(t=0) and then var(t=1) and therefore
the formula did not work:
generate var = 0.95*(var[_n-1]) + 0.05*return[_n]^2

Thanks for yur help.

Kind regards,

Nadine
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index