I would like to fill missing observations in a panel. I found the mipolate command, that seems adequate. The issue now is that I would like to compute the average for missing values between two observed ones, and carry values backwards/forwards if one of those end/start points is missing. The mipolate command seems to do this, but only for the mid point in the interval it takes the mean. It replaces all other values by cascading forwards/backwards.
So in the extract bellow, flow_ex in row 16. 17. and 18. should be =50.976. Is there a way to adjust the command?
Thanks for your feedback,
Yannik
Code:
by census: mipolate flow_combined1 year, generate(flow_extra2) nearest list year census flow_combined1 flow_extra2 if census==11 +--------------------------------------+ | year census flow_c~1 flow_ex~2 | |--------------------------------------| 11. | 1979 11 0 0 | 12. | 1978 11 10 10 | 13. | 1977 11 0 0 | 14. | 1976 11 10 10 | 15. | 1975 11 0 0 | |--------------------------------------| 16. | 1974 11 . 0 | 17. | 1973 11 . 50.976059 | 18. | 1972 11 . 101.95212 | 19. | 1971 11 101.9521 101.95212 | 20. | 1970 11 70.672 70.671997 | +--------------------------------------+
0 Response to Fill missing values with means using mipolate
Post a Comment