[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 |
Mon, 7 Dec 2009 19:56:39 +0000 |

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 > > Beatrice Crozza > > 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/

**Follow-Ups**:**RE: st: RE: Intraday volatility***From:*"Martin Weiss" <martin.weiss1@gmx.de>

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

- Prev by Date:
**Re: st: Summarizing data by Timestamps** - Next by Date:
**RE: st: RE: Intraday volatility** - Previous by thread:
**RE: st: RE: Intraday volatility** - Next by thread:
**RE: st: RE: Intraday volatility** - Index(es):

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