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: scaling by average


From   Claudius Li <[email protected]>
To   [email protected]
Subject   st: scaling by average
Date   Tue, 11 Dec 2012 16:10:50 -0500

I've got an other question on the panel data set from my previous post.
I've reshaped it so that I now have

date state score time <other stuff>

I want to add a variable normalized_score = score - average_for_day
Where average_for_day = sum(score * count + score[n-7] * count[n-7]
+score[n+7] * count[n+7] ... ) / sum(count + count[n-7] + count[n+7]
... )

It seems a bit complicated to do this with loops. Is there a simpler way?

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