Bookmark and Share

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


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

Re: st: calculating a mean value using the rolling command


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: calculating a mean value using the rolling command
Date   Thu, 31 Mar 2011 09:26:23 +0100

The aim of -egen- is to return a variable, in this case holding a
single mean. That is overkill at the best of times, but it is not what
you want here.

-egen- is not an r-class or e-class command. But on the side, -egen-
uses -count- to count non-missing values, the result of which is what
you are seeing.

You should be using -summarize-. There are examples using -summarize-
to collect means in the help for -rolling-, so I need not invent any
here.

Correct spelling is "Stata".

Nick

On Thu, Mar 31, 2011 at 2:43 AM, Nat Tharnpanich <[email protected]> wrote:

>   I would like to calculate rolling mean values of a variable in overlapping
> time periods using rolling command in STATA. I typed
>
> rolling, window(20) clear: egen avg = mean(var name)
>
> However, STATA returned r(N) which is the number of years in the sample
> rather that the mean value I wanted. What have I done wrong???

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index