The weight is variable: order
I know in order to calculate the cumulative mean by groups, we can use
Code:
rangestat (mean) cumulative=score ,interval(order -18 -1) by(ID)
For example, for observation 2, the expected value is 68.8*1, for observation 3, the expected value is 68.8*1/(1+2)+73.7*2(1+2).
Many thanks!
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input double score byte order float ID
68.8 1 1
73.7 2 1
76.46000000000001 3 1
71.74 4 1
57.8 5 1
70.2 6 1
62.4 7 1
77.97999999999999 8 1
69.46000000000001 9 1
79.1 10 1
67.96000000000001 12 1
69.03999999999999 13 1
68.16 15 1
76.03999999999999 16 1
63.9 1 2
68.8 2 2
60 3 2
64.8 4 2
78.1 5 2
75.9 6 2
71.2 7 2
58.2 8 2
59.5 9 2
64.2 10 2
60.6 11 2
67.9 12 2
74.5 13 2
70.3 14 2
66.8 15 2
64.4 16 2
77.3 17 2
end
0 Response to How to calculate the cumulative mean with different weights by groups?
Post a Comment