Alright! Here we have only one ID. The problem is that for this ID we have 2 missing records in the sales. The 2 missing sales could be anywhere! Please see here some of possible cases of missing sales for months: 1)we may have 2 missing sales in months 201811,201812 -> in this case we want to get the average of the next 3 months so the program should impute the sales from month :201812 first (from months:201901,201902,201903) ,and then to impute 201811 sales from the average of the three next including sales of (201812,201901,201902) 2)we may have 2 missing sales in months 201811,201902 -> in this case it should impute the sales of 201902 month first (from the avg of the sales from months:201903,201904,201905) and when it is filled with a value it should impute the sales of month 201811 (from the avg of the sales of 201811 we imputed,from sales of 201812 and 201901) 3) we may have 2 missing sales in months 201907,201908-> in this case we need to impute first the sales of 201907 (from the avg of the previous 3 months: 201904,201905,201906) and then to impute the missing sales of 201908, because we will use the imputed value from month 201907.So,the sales of month 201908 should imputed from the avg of sales of months(201905,201906,201907-this should be the imputed value ) 4) we may have 2 missing sales in months 201911,201912(the last 2 months of an ID) -> in this case we need to impute the sales of of 201911 from the avg of the previous 3 months( 201908,201909,201910) and when it is imputed we will continue with the imputation of sales of 201912 from the avg of the previous 3 (incl. the new imputed value 201911) .So, it will be the avg of sales from months(201911,201910,201909). I hope it makes sense now.
... View more