Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: RE: Re: rolling standard deviation [was: ""]


From   Austin Nichols <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: Re: rolling standard deviation [was: ""]
Date   Wed, 29 Jun 2011 13:57:54 -0400

florian et al.
Note that using the business calendar or redefining elapsed days in
another way and then estimating a SD on pooled data requires an
assumption about poolability.  If changes in the data-generating
process accrue daily (not just Mon-Fri) and exhibit positive serial
correlation, then changes over three days could well exhibit a much
higher SD than one-day changes, which might be a difference of
substantial import, depending on what you intend to do with the
estimated SD.  But you could check this in your data like so:

sysuse sp500, clear
g dow=dow(date)
tsset date
g dd=date-date[_n-1]
ta dow dd
levelsof dd, loc(ds)
g d=.
qui foreach d of loc ds {
 g d`d'=ln(close)-ln(L`d'.close)
 replace d=d`d' if dd==`d'
 }
su d1 if dd==1
su d3 if dd==3
su
g faked=_n
tsset faked
rolling, w(30) keep(date) clear nodots:su d
su sd

Note that the above calculates the SD for each day over the last 30
business days and you might want 126 business days to represent 6
calendar months, or 130 days; if you really wanted the last 6 calendar
months you would need to define more precisely how you want to measure
that (all business days back to the same number day in that past
month? what about Aug 31?).

On Wed, Jun 29, 2011 at 8:25 AM, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> Stata 12 supports business calendars:
>
> http://www.stata.com/stata12/business-calendars/
>
> Nick
> n.j.cox@durham.ac.uk
>
> Maarten Buis
>
> On Wed, Jun 29, 2011 at 1:29 PM,  wrote:
>> I'm having a hard time trying to calculate the standard deviation of the first difference of logarithms of daily exchange rates for the past 6 month (or 180 days).
>>
>> As I'm using a huge dataset with daily data, I have gaps (or missings, if I use the fillin command before).
>
> Such gaps are often the result of the fact that the data is not
> generated by a daily process, e.g. no data for weekends and holidays.
> In that case the calender time is not the appropriate time axis when
> doing your analysis. For solutions see: Christopher F. Baum (2007)
> "Stata tip 40: Taking care of business" The Stata Journal, 7(1):
> 137--139. <http://www.stata-journal.com/article.html?article=dm0028>
>
> For computing the standard deviation of the past six months I would
> use -rolling-, see: -help rolling-.
>

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index