Bookmark and Share

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

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

st: moving average of the last 55 time points

From   Juan Fernandez <>
Subject   st: moving average of the last 55 time points
Date   Mon, 30 Jan 2012 09:45:01 +0100

Hi everyone,

I am trying to obtain moving averages that take into account the
previous 55 time points (in this case, years) in a panel data setting.
However I cannot find any Stata command that can solve the problem. To
my knowledge, -egen, ma()- doesn't do the trick because it cannot be
combined with -by-. Moreover, -tssmooth ma, window()- doesn't do it
either because it is limited in the number of lags it can consider.

Is there any way to calculate a moving average for each case that
takes into account the last 55 time data points (even if there are
some isolated missings in a few years)?

The data structure is as follows:

Country                   Year         IV
1                              1945       20
1                              1946       33
...                              ...         ...
1                              2000       36
2                              1945       31
2                              1946       27
...                              ...         ...
2                              2000       29

Thanks in advance! Best,

*   For searches and help try:

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