Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: scaling by average


From   Claudius Li <claudiusli@janysanalytics.com>
To   statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index