Hello there ! I am hoping to get a reply for this since I am struggling with it for quite some time today.
What i want to do basically is to create a new variable that will give the mean of the past 5 observations of another variable. So for instance for the data i post below I want to have variable that provides the average temperature (Temp_G~g) the past five minutes (i.e Temp_G~g_n - Temp_G~g_n-4) . Of course at certain time points I have missing data for temperature.
I noticed that it is recommended in other posts to sum the past 5 observations and then divide by the number of past non-missing observations, yet i still cant get the code quite right. Can someone help me with this !??
Thank you,
George
+--------------------------------+
| Date_Time2 Temp_G~g |
|--------------------------------|
1. | 27/05/2019 09:47:00 25.9 |
2. | 27/05/2019 09:48:00 26.0 |
3. | 27/05/2019 09:49:00 26.0 |
4. | 27/05/2019 09:50:00 26.1 |
5. | 27/05/2019 09:51:00 26.1 |
|--------------------------------|
6. | 27/05/2019 09:52:00 26.2 |
7. | 27/05/2019 09:53:00 26.1 |
8. | 27/05/2019 09:53:59 26.1 |
9. | 27/05/2019 09:55:00 26.1 |
10. | 27/05/2019 09:56:00 26.1 |
|--------------------------------|
11. | 27/05/2019 09:57:00 26.2 |
12. | 27/05/2019 09:58:00 26.1 |
13. | 27/05/2019 09:59:00 26.1 |
14. | 27/05/2019 10:00:00 26.1 |
15. | 27/05/2019 10:01:00 26.3 |
|--------------------------------|
16. | 27/05/2019 10:01:59 26.3 |
17. | 27/05/2019 10:03:00 26.4 |
18. | 27/05/2019 10:04:00 26.3 |
19. | 27/05/2019 10:05:00 26.2 |
20. | 27/05/2019 10:06:00 26.2 |
+--------------------------------+
Related Posts with Averaging observations within a column having missing values
Each table on a new page using asdocHello everyone, I am running DEA models and I was wondering if it is possible to start the output o…
Dumitrescu & Hurlin (2012) Granger non-causality testHello Dears, I am trying to see the granger causality between government revenue and government spen…
interpretation of log-linear model vid interaction termHello! I'm having a hard time interpreting my results from my regression which is: Ln(sales) = bet…
Standardizing categorical variablesDear Statalist, I am running a linear probability model with categorical variables. Some of the ind…
Displaying Significance Stars in combined summary and correlations tableDear Forum, i merged my correlations and summary statistics to one table via the below code (thanks…
Subscribe to:
Post Comments (Atom)
0 Response to Averaging observations within a column having missing values
Post a Comment