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]

st: creating moving averages for long periods


From   Mihaly Fazekas <[email protected]>
To   [email protected]
Subject   st: creating moving averages for long periods
Date   Thu, 11 Jul 2013 15:03:23 +0100

Hi,

I am Mihaly Fazekas from the University of Cambridge working on a
panel database containing daily data on companies' new contracts
concluded for a period of several years.

I want to calculate a 12 months running average of each company's
contract volume (I will actually want total contract volumes but that
is a simple multiplication once the average is obtained).
Unfortunately, no running mean technique works as my time-span is too
long (365 days). I tried the following three approaches without
success:

tssmooth ma sz_s_iw_sum12=sz_s_iw_perd_sum, w(364 1)
egen sz_s_iw_sum12 = filter(sz_s_iw_perd_sum), lags(-364/0)
by iw_id : gen sz_s_iw_sum12
=L364.sz_s_iw_perd_sum+L363.sz_s_iw_perd_sum+...+sz_s_iw_perd_sum

where sz_s_iw_sum12 is the new variable containing the running average
for each day and sz_s_iw_perd_sum is the daily contract value for each
firm in my panel. The panel is unbalanced, but I filled it in with 0-s
where no contract was concluded. I am using stata 12. I have several
thousand firms in the panel so efficiency of calculations is
imperative.

Any help is appreciated,
Mihaly
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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