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

Re: st: Weighted daily mean

From   Neil Shephard <>
Subject   Re: st: Weighted daily mean
Date   Thu, 16 Oct 2008 12:15:07 +0100

Beatrice Crozza wrote:
> Dear all,
> 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.
Why don't you think the result is correct?

> Do you have any idea of how to calculate a mean, taking into account
> the daily mean?
I think you've got the wrong answer because you are treating each day as
equal, when in fact one day may have more observations than another.  In
these instances you want to apply a weight to the daily trademean that
you are including.  However its simpler to just work with the raw data
and take the overall mean for the period you are analysing, in which
case you just ignore the -, by(date)- option..

egen trademeantot=mean(trade)


"We should make things as simple as possible, but not simpler" - Anon (not Albert Einstein)

This  message  may  contain  confidential and  privileged  information.
If you  are not the  intended recipient  you should not  disclose, copy
or distribute information in this e-mail or take any action in reliance
on its contents.  To do so is strictly  prohibited and may be unlawful.
Please  inform  the  sender that  this  message has  gone astray before
deleting it.  Thank you.

2008 marks the 60th anniversary of the NHS.  It's an opportunity to pay
tribute to the NHS staff and volunteers who help shape the service, and
celebrate their achievements.

If you work for the NHS  and  would like  an NHSmail  email account, go

*   For searches and help try:

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