Hi there, I am trying to calculate the rolling standard deviation, skewness and kurtosis via Rangestat (SSC) by using the below code for a fixed window of 12 months, but I am unable to get the fixed window and it is giving results from 2 months till reached to 12 and then 12 onwards for each ID. so I added some more steps to restrict it to 12 months only. Please advise if that is the right way of doing this or I can find the fixed window directly via Rangestat. any help would be appreciated. Regards, Sara
Code:
isid ID modate1, sort
rangestat (sd) sd_ret=RET (skewness) sk_ret=RET (kurtosis) kr_ret=RET (count) cmnth=RET, interval(modate1 -11 0) by(ID)
Code:
/**To use only 12 months rolling stats**/
clonevar cmnth1 = cmnth
replace cmnth1 = . if cmnth1 < 12
clonevar sd_ret1 = sd_ret
replace sd_ret1 = . if cmnth < 12
clonevar sk_ret1 = sk_ret
replace sk_ret1 = . if cmnth < 12
clonevar kr_ret1 = kr_ret
replace kr_ret1 = . if cmnth < 12