Dear STATALIST,
I am interested in creating the discounted cumulative sum of preceding values of a variable. I have the following unbalanced panel data with many missing observations. I filled in the gaps between the available calendar years, and this is why the current data set has complete years regardless of missing observations. Year and time variables are the same. I am trying to generate the discounted cumulative sum using the variable (performance).
The equation for the discounted sum is as following:

P1 is performance of the focal firm i at time 1 (first firm-year observation). T is the given time of the focal firm i.
For example, for the 5th observation (firm 102, time 5), the discounted sum from 1995 to 1998 should be calculated as 13474868 * (1/5-1) + 26222656 * (1/5-2) + 74088704 * ( 1/5-4). Therefore, I will get the following discounted sum values based on this equation. The discounted sum of any first observation of each firm should be zero since there is no preceding value. Any missing observation will be excluded in the equation.
I would like to know if there is a way to generate this variable with loops (or any simpler way).
Any suggestions or advice would be greatly appreciated. Thank you in advance for your help.
Best regards,
Anna
I am interested in creating the discounted cumulative sum of preceding values of a variable. I have the following unbalanced panel data with many missing observations. I filled in the gaps between the available calendar years, and this is why the current data set has complete years regardless of missing observations. Year and time variables are the same. I am trying to generate the discounted cumulative sum using the variable (performance).
firm | year | time | performance |
102 | 1995 | 1 | 13474868 |
102 | 1996 | 2 | 26222656 |
102 | 1997 | 3 | . |
102 | 1998 | 4 | 74088704 |
102 | 1999 | 5 | . |
102 | 2000 | 6 | 69155080 |
102 | 2001 | 7 | 39108876 |
109 | 2006 | 1 | 1787580.5 |
109 | 2007 | 2 | . |
109 | 2008 | 3 | 9137924 |
P1 is performance of the focal firm i at time 1 (first firm-year observation). T is the given time of the focal firm i.
For example, for the 5th observation (firm 102, time 5), the discounted sum from 1995 to 1998 should be calculated as 13474868 * (1/5-1) + 26222656 * (1/5-2) + 74088704 * ( 1/5-4). Therefore, I will get the following discounted sum values based on this equation. The discounted sum of any first observation of each firm should be zero since there is no preceding value. Any missing observation will be excluded in the equation.
firm | time | discounted sum |
102 | 1 | 0 |
102 | 2 | 13474868 * (1/2-1) |
102 | 3 | 13474868 * (1/3-1) + 26222656 * (1/3-2) |
102 | 4 | 13474868 * (1/4-1) + 26222656 * (1/4-2) |
102 | 5 | 13474868 * (1/5-1) + 26222656 * (1/5-2) + 74088704 * ( 1/5-4) |
102 | 6 | 13474868 * (1/6-1) + 26222656 * (1/6-2) + 74088704 * ( 1/6-4) |
102 | 7 | 13474868 * (1/7-1) + 26222656 * (1/7-2) + 74088704 * ( 1/7-4) + 69155080 * (1/7-6) |
109 | 1 | 0 |
109 | 2 | 1787580.5 * (1/2-1) |
109 | 3 | 1787580.5 * (1/3-1) |
Any suggestions or advice would be greatly appreciated. Thank you in advance for your help.
Best regards,
Anna
Comment