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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

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

Subject |
st: RE: Weighted daily mean |

Date |
Thu, 16 Oct 2008 12:17:45 +0100 |

This is not to me a simple question as you don't spell out fully what is going on. I guess that you have a variable number of trades on each day. In that situation, the mean over trades and the mean over days (the mean of daily means) will probably differ. If you want a mean over trades, that would be easiest got by . summarize trade And if you want that in a variable (difficult to see why), you could then go . gen trademeantot = r(mean) Your second statement is equivalent, but a bit inefficient. Still, by the time you have typed two commands not one, you wouldn't notice. If you want a mean over days, each day being given equal weight, then you could go egen tag = tag(date) su trademean if tag and if necessary gen trademeantot = r(mean) Nick n.j.cox@durham.ac.uk Beatrice Crozza maybe again a simple question, but I tried to read the help and I didn't find a solution. I have calculated a daily mean for my variable trade, typing: egen trademean=mean(trade), by(date) now I want to calculate the total mean, so I typed: egne trademeantot=mean(trademean) but I don't think that the result is correct. Do you have any idea of how to calculate a mean, taking into account the daily mean? * * 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: Weighted daily mean***From:*"Beatrice Crozza" <beatrice.crozza@gmail.com>

- Prev by Date:
**st: RE: Weighted daily mean** - Next by Date:
**st: RE: Programming a loop to exclude M&As in the 5 years prior to an M&A** - Previous by thread:
**st: RE: Weighted daily mean** - Index(es):

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