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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

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

Subject |
RE: st: RE: Intraday volatility |

Date |
Mon, 7 Dec 2009 21:04:27 +0100 |

<> " 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/

**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>

- Prev by Date:
**RE: st: RE: Intraday volatility** - Next by Date:
**Re: st: -merge- in version11 fails to sort automatically** - Previous by thread:
**RE: st: RE: Intraday volatility** - Next by thread:
**Re: st: RE: Intraday volatility** - Index(es):

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