Dear All, In my GMM analysis I explain depression_score with it's lag and average income occured in between two depression measurements. As I cannot include income in average income calculation if it is occured after depression measurement, I am trying to calculate the average income in between two consecutive depression measurement rounds by individuals in panel data. However, the window in between two consecutive round for depression is not fixed and there are missing observations for depression. If depression score is missing average should treat the week of first occurrence of round as the previous depression measurement week.
My data looks like:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float ID byte week float round double income float depression_score 1 1 1 . . 1 2 1 . . 1 3 1 . . 1 4 1 . . 1 5 1 . . 1 6 1 . . 1 7 1 . . 1 8 1 . . 1 9 1 . . 1 10 2 . . 1 11 2 1.5 . 1 12 2 . . 1 13 3 . 4 1 14 3 . . 1 15 3 . . 1 16 4 1 . 1 17 4 1.5 0 1 18 4 . . 1 19 4 1.5 . 1 20 5 . 6 1 21 5 . . 1 22 5 1.2 . 1 23 5 0 . 1 24 6 5 . end
For example, average income is 0 for the first two waves as there is no income reported until the first depression measurement. In wave 3, average income will be calculated among week 11, 12, 13. As depression_score is missing in the previous wave 2, I restrict the window and exclude week 10 in average income of wave 3, which the first week of wave 2. For wave 4, only week 14,15 , 16 and 17 will be included in the calculation of average income. For wave 5 only week 18, 19, 20 will be included in the calculation. For wave 6, week 21,22,23,24 will be included in the calculation. The new variable will look like:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float ID byte week float round double income float depression_score double avg_income 1 1 1 . . . 1 2 1 . . . 1 3 1 . . . 1 4 1 . . . 1 5 1 . . . 1 6 1 . . . 1 7 1 . . . 1 8 1 . . . 1 9 1 . . . 1 10 2 . . . 1 11 2 1.5 . . 1 12 2 . . . 1 13 3 . 4 1.5 1 14 3 . . 1 15 3 . . 1 16 4 1 . 1 17 4 1.5 0 1.25 1 18 4 . . 1 19 4 1.5 . 1 20 5 . 6 1.5 1 21 5 . . 1 22 5 4 . 1 23 5 0 . 1 24 6 5 . 3 end
Nick Cox
Best regards,
Nursena
Comment