Hi all,
First time post so bare with me if I've left out any critical details.
I'm using STATA version 12.1 on Mac.
I'm trying to calculate by ID, Season, and Phase the running standard deviation up to any given date.
Example dummy data below. There is not a training session on every day hence the missing data and I only want to include dates where there was a session in the standard deviation calculation. If there is a change in ID, Season, or Phase I would like the standard deviation calculation to reset and start again.
Example 1, for ID 1 on the 8/1/16 I would like the SD from 1/1/16 to the 7/1/16. Example 2, for ID 1 on the 17/1/16 I would like the SD from 1/1/16 to the 16/1/16.
It's a time series dataset and therefore I set it accordingly:
tsset ID Date
tsfill
Any help on this would be greatly appreciated!
First time post so bare with me if I've left out any critical details.
I'm using STATA version 12.1 on Mac.
I'm trying to calculate by ID, Season, and Phase the running standard deviation up to any given date.
Example dummy data below. There is not a training session on every day hence the missing data and I only want to include dates where there was a session in the standard deviation calculation. If there is a change in ID, Season, or Phase I would like the standard deviation calculation to reset and start again.
Example 1, for ID 1 on the 8/1/16 I would like the SD from 1/1/16 to the 7/1/16. Example 2, for ID 1 on the 17/1/16 I would like the SD from 1/1/16 to the 16/1/16.
It's a time series dataset and therefore I set it accordingly:
tsset ID Date
tsfill
Date | ID | Season | Phase | Distance |
1/1/16 | 1 | 2016 | 1 | 8000 |
2/1/16 | 1 | 2016 | 1 | . |
3/1/16 | 1 | 2016 | 1 | 4000 |
4/1/16 | 1 | 2016 | 1 | . |
5/1/16 | 1 | 2016 | 1 | 3000 |
6/1/16 | 1 | 2016 | 1 | . |
7/1/16 | 1 | 2016 | 1 | . |
8/1/16 | 1 | 2016 | 1 | 2000 |
9/1/16 | 1 | 2016 | 1 | . |
10/1/16 | 1 | 2016 | 1 | . |
11/1/16 | 1 | 2016 | 1 | 7000 |
12/1/16 | 1 | 2016 | 1 | . |
13/1/16 | 1 | 2016 | 1 | . |
14/1/16 | 1 | 2016 | 1 | 9000 |
15/1/16 | 1 | 2016 | 1 | . |
16/1/16 | 1 | 2016 | 1 | . |
17/1/16 | 1 | 2016 | 1 | 8000 |
18/1/16 | 1 | 2016 | 1 | . |
19/1/16 | 1 | 2016 | 1 | 4000 |
20/1/16 | 1 | 2016 | 2 | . |
21/1/16 | 1 | 2016 | 2 | 3000 |
22/1/16 | 1 | 2016 | 2 | . |
23/1/16 | 1 | 2016 | 2 | . |
24/1/16 | 1 | 2016 | 2 | 2000 |
25/1/16 | 1 | 2016 | 2 | . |
26/1/16 | 1 | 2016 | 2 | . |
27/1/16 | 1 | 2016 | 2 | 7000 |
28/1/16 | 1 | 2016 | 2 | . |
29/1/16 | 1 | 2016 | 2 | . |
30/1/16 | 1 | 2016 | 2 | 7000 |
31/1/16 | 1 | 2016 | 2 | . |
1/2/16 | 1 | 2016 | 2 | 8000 |
2/2/16 | 1 | 2016 | 2 | . |
3/2/16 | 1 | 2016 | 2 | . |
4/2/16 | 1 | 2016 | 2 | 9000 |
5/2/16 | 1 | 2016 | 2 | . |
1/1/16 | 2 | 2016 | 1 | 8000 |
2/1/16 | 2 | 2016 | 1 | . |
3/1/16 | 2 | 2016 | 1 | 4000 |
4/1/16 | 2 | 2016 | 1 | . |
5/1/16 | 2 | 2016 | 1 | 3000 |
6/1/16 | 2 | 2016 | 1 | . |
7/1/16 | 2 | 2016 | 1 | . |
8/1/16 | 2 | 2016 | 1 | 2000 |
9/1/16 | 2 | 2016 | 1 | . |
10/1/16 | 2 | 2016 | 1 | . |
11/1/16 | 2 | 2016 | 1 | 7000 |
Comment