On Mon, May 21, 2012 at 9:20 PM, Hideyoshi Maeda
<hideyoshi.ma...@gmail.com>wrote:

> Doing a quick comparison of the difference in code for the volatility
> estimate in using 'yang.zhang' as a calculation method,
>
 on S&P 500 data, going back from the beginning of 2001 till today (22 May
2012). These were the results from the following lines of code:

>
> N.B. volatility.new is the edited code with the suggestion of using runVar
> instead  of runSum, as suggested by James
> N.B SPX.ohlc is an xts object of that contains OHLC data for the Bloomberg
> ticker "SPX Index"
>
> > original.vol.code <- volatility(SPX.ohlc, calc="yang.zhang")
> > new.vol.code <- volatility.new(SPX.ohlc, calc="yang.zhang")
> > plot((new.vol.code-original.vol.code)*100/original.vol.code, main="%
> difference in volatility esitimates
> +      when comparing new and old code")
>
> Some quite significant percentage differences getting up to approx. -10%
> viewing it as a histogram in terms of differences, you get...
>


I was actually surprised that the calculation isn't off by more, but the
inner runSum which calculates a rolling mean is usually fairly stable,
especially for longer n.  I don't know if Bloomberg can calculate
volatility via yang.zhang, but that would be a worthwhile reference to
compare.

Best,

James

        [[alternative HTML version deleted]]

_______________________________________________
R-SIG-Finance@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

Reply via email to