Dear all,
I have a seemingly easy question that is giving me some trouble. The following table is a piece of my data set, which is on firm acquisitions. Value transaction is the price paid to acquire a certain firm, acquiror id is a unique id for an acquiror, and date is the date of an acquisition. I would like to calculate the moving average of the transaction value of acquisitions a firm made in the previous 4 years. There seem to be two problems here. The first is that date is recorded in days, and I would like to have the moving average in terms of years. Second, as you can see, not every company made multiple deals. For instance, acquiror_id=919 didn't make any acquisition in the past. For those cases, I would like the moving average to report a value of 0.
Following the time series manual and other threads, I did the following
Note that 1460 corresponds to the number of days of four years 365*4. This code however generated an error which said that 1460 is out of the allowed range. Do you know by any chance how to solve this?
Many thanks!
Riccardo
I have a seemingly easy question that is giving me some trouble. The following table is a piece of my data set, which is on firm acquisitions. Value transaction is the price paid to acquire a certain firm, acquiror id is a unique id for an acquiror, and date is the date of an acquisition. I would like to calculate the moving average of the transaction value of acquisitions a firm made in the previous 4 years. There seem to be two problems here. The first is that date is recorded in days, and I would like to have the moving average in terms of years. Second, as you can see, not every company made multiple deals. For instance, acquiror_id=919 didn't make any acquisition in the past. For those cases, I would like the moving average to report a value of 0.
Following the time series manual and other threads, I did the following
Code:
tsset acquiror_id date tssmooth ma avgvalue4yr=value_transaction, window(1460)
value_transaction | acquiror_id | date |
61.1 | 918 | 01/01/1994 |
1088.367 | 918 | 24/06/1994 |
1568.947 | 918 | 07/03/1996 |
1660.504 | 918 | 14/06/1997 |
86.32 | 919 | 18/05/1994 |
730 | 920 | 26/11/1986 |
123.037 | 920 | 31/01/1987 |
1493.323 | 920 | 30/04/1993 |
85.9 | 921 | 02/01/2001 |
109.461 | 921 | 03/01/2001 |
120.71 | 921 | 01/06/2001 |
83 | 921 | 27/10/2001 |
104.154 | 921 | 10/05/2003 |
1011.336 | 921 | 06/12/2005 |
72.266 | 921 | 02/06/2007 |
80.809 | 922 | 26/01/2001 |
Many thanks!
Riccardo
Comment