 Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: RE: Variable Estimation

 From Nick Cox To "'statalist@hsphsun2.harvard.edu'" Subject st: RE: Variable Estimation Date Sun, 7 Nov 2010 17:13:06 +0000

```This is difficult to follow.

For example, where does the r(n) you refer to come from?

You seem to be trying to put the mean into a variable, but what you will have in -r_m- is itself a variable, the mean so far, not in general the overall mean.  Also, your calculation assumes no missing values.

I suggest you read the documentation for -summarize- and -egen-.

Nick
n.j.cox@durham.ac.uk

Léon Bueckins

I try to estimate the following variable, basing upon this equation: http://cl.ly/34Px
But somehow I can't get it to work properly, so I may need some help. The problem is that N is different for each t.

*get number of groups per t
bysort igroup : g trun =_n
local nGroups =r(n)

*get mean return per t = r_m,t
g r_m = (sum(return))/_n