Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Oliver Jones <ojones@wiwi.uni-bielefeld.de> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: calculate volatility in different ways |

Date |
Tue, 26 Jul 2011 17:48:42 +0200 |

Hi, dose this help you? ********** Begin example **************** sysuse sp500, clear tsset date rolling Var = r(Var), window(60) step(1): summarize open, d list in 1/10 ********** End example **************** Best Oliver Am 25.07.2011 13:00, schrieb Nadine R:

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/

-- Universität Bielefeld Fakultät für Wirtschaftswissenschaften Lehrstuhl für Ökonometrie und Statistik - - Bielefeld University Faculty of Business Administration and Economics Chair of Econometrics and Statistics - - Raum / room: V9-110 Tel / phone: +49 (0)521 106 4871 --- * * 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/

**Follow-Ups**:**Re: st: calculate volatility in different ways***From:*tzygmund mcfarlane <tzygmund@googlemail.com>

**References**:**st: calculate volatility in different ways***From:*Nadine R <tanzmaus1986@googlemail.com>

- Prev by Date:
**Re: st: RE vs Pooled OLS - On the Breusch-Pagan LM test** - Next by Date:
**Re: st: Working with pgmhaz8** - Previous by thread:
**st: calculate volatility in different ways** - Next by thread:
**Re: st: calculate volatility in different ways** - Index(es):