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

From |
"Tharyan, Rajesh" <R.Tharyan@exeter.ac.uk> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: RE: Intraday volatility |

Date |
Tue, 8 Dec 2009 12:25:25 +0000 |

Ok.. id does stand for some timeid then. In that case, assuming that your data has for each day returns measured at 5 minute intervals, the intraday volatility, which is the volatility of the returns measured at five minute intervals for each day, is calculated as egen st=sd(return), by(date). Rajesh -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Beatrice Crozza Sent: 08 December 2009 11:59 To: statalist@hsphsun2.harvard.edu Subject: Re: st: RE: Intraday volatility Dear Martin and Rajesh, I have intra-day data, since my id stands for 5-min intervals. So I should have what I am looking with the command: egen st=sd(return), by(date id) but I receive all missing values. What I am doing wrong? Thanks, Bea 2009/12/7 Martin Weiss <martin.weiss1@gmx.de>: > > <> > > " You can see this using Martin's example which I modified" > > Beatrice should omit the -compress- command, which starts with a capital > letter in Rajesh`s reply. It is not needed here, anyway, since I gave clear > instructions to -input- in this case. It continues to appear in my posts > because it is part of my personal "input" template. > > HTH > Martin > > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Tharyan, Rajesh > Sent: Montag, 7. Dezember 2009 20:57 > To: statalist@hsphsun2.harvard.edu > Subject: RE: st: RE: Intraday volatility > > Hi, > > Others have pointed out why you get missing when you try to compute sd by(id > date). If you are trying to compute the intra-day volatility for each id you > need intra-day data (by the minute or tick data), in that case, for each > date, for each id you should have several returns. Your data apprears to be > daily data (Unless id stands some timeid). So you need to think again about > what you are trying to do. > > Re you statement "but I don't know how to insert also the date, so that I > can compute the intraday volatility" > > I suppose that refers to the missing dates in your example (the date is > missing for id 2 and 3).You can see more here > http://www.stata.com/support/faqs/data/missing.html > You can insert the dates by > > replace date= date[_n-1] if date>= . > > You can see this using Martin's example which I modified > > ******* > clear* > > input str10 Date return byte id > "02/01/2009" .0003247 1 > "" .005724 2 > "" .0001587 3 > "03/01/2009" .0000997 1 > "" .0002494 2 > "" .000071 3 > "05/01/2009" .0001245 1 > "" .00015879 2 > "" .0003546 3 > end > > Compress > > gen date=date(Date, "DMY") > format date %tdMonth_DD,_CCYY > list > replace date= date[_n-1] if date>= . > list > ************* > > Hope this helps > rajesh > > -----Original Message----- > From: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox > Sent: 07 December 2009 18:32 > To: statalist@hsphsun2.harvard.edu > Subject: RE: st: RE: Intraday volatility > > Your problem was Martin's point, just made. If you have one measurement for > each combination of day and id, there is no variability to measure. In > addition, Stata uses n - 1 within the formula for s.d. so the result is > missing. So, no surprise there. > > Nick > n.j.cox@durham.ac.uk > > Beatrice Crozza > > yes, volatility means standard deviation. > > I already tried what you suggested me but I received all missing values. > Why? > > 2009/12/7 Nick Cox <n.j.cox@durham.ac.uk>: > >> If volatility means here standard deviation, as I infer, then >> >> egen st = sd(return), by(id date) >> >> may be what you want. >> >> Nick >> n.j.cox@durham.ac.uk >> >> these are my data: >> >> Date return id >> 02/01/2009 .0003247 1 >> .005724 2 >> .0001587 3 >> >> 03/01/2009 .0000997 1 >> .0002494 2 >> .000071 3 >> >> 05/01/2009 .0001245 1 >> .00015879 2 >> .0003546 3 >> >> I would like to compute the intraday volatility, i.e. the volatility >> for each day divided by the id. >> I typed: >> egen st=sd(return), by (id) >> >> but I don't know how to insert also the date, so that I can compute >> the intraday volatility. > > * > * 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/ > > * > * 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/ > > > * > * 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/ > * * 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/ * * 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/

**References**:**st: Intraday volatility***From:*Beatrice Crozza <beatrice.crozza@gmail.com>

**st: RE: Intraday volatility***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: RE: Intraday volatility***From:*Beatrice Crozza <beatrice.crozza@gmail.com>

**RE: st: RE: Intraday volatility***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**RE: st: RE: Intraday volatility***From:*"Tharyan, Rajesh" <R.Tharyan@exeter.ac.uk>

**Re: st: RE: Intraday volatility***From:*Beatrice Crozza <beatrice.crozza@gmail.com>

- Prev by Date:
**AW: st: RE: Intraday volatility** - Next by Date:
**st: re: instrumental variables estimation problems** - Previous by thread:
**AW: st: RE: Intraday volatility** - Next by thread:
**st: RE: Intraday volatility** - Index(es):

© Copyright 1996–2014 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |