Hello I am trying to calculate the rolling average of the past 36 months (periods) and when I run the code using rangestat the new variable results in all missing values. I am not sure how to fix this and output the correct calculation.
Here is an example of my sample:
This is my code to calculate the 36 month moving average.
Here is an example of my sample:
Code:
input double date long _ID float country_pdsi 4.733856e+11 9 1.5002956 4.76064e+11 9 1.7449586 4.784832e+11 9 1.6589595 4.811616e+11 9 1.4847733 4.837536e+11 9 1.0025214 4.86432e+11 9 .8517559 4.89024e+11 9 .7509255 4.917024e+11 9 .7988663 format %tc date
Code:
xtset _ID date rangestat (mean) country_pdsi, interval(date -36 -1) by(_ID)
Comment