Tuesday, February 28, 2006

st: weighted cumulative sum

Hello,

I have a panel data of firms and the number of units of products they sell each year. I am trying to generate some measures of production experience.

One measure I have simply produces a cumulative sum of the number of products sold up to the previous year: by id: gen experience1=sum(products[_n-1])

I am now trying to produce more sophisticated measures that will discount the experience by some given rate (by, say, dividing the experience by its age). The idea is that last year's experience is more valuable than the experience of the year before it and so on.

For example, if I have the following dataset

year 1 - 30 products year 2 - 20 products year 3 - 10 products year 4 - 10 products year 5 - 20 products

Right now, my experience measure for year 4 is 30+20+10=60. I am looking for a command that will give me the following value: (30/3)+(20/2)+(10/1)=30

Any idea how can this be done?

Cheers,

Arik Lifschitz

__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/


Tag:


Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?