# Replacing outliers with the median value of the preceding 5 observations

In the paper Implications of dynamic factor models for VAR analysis the authors propose a a technique for removing outliers in variables used for dyanamic factors analysis:

"The outlier adjustment entailed replacing observations of the transformed series with absolute median deviations larger than 6 times the inter quartile range [IQR] by with the median value of the preceding 5 observations" (Stock and Watson, 2005)

What happens if the first outliers lie in the first four observations?. For example, consider the following variable:

$$\textrm{Median Value} = 41.3$$

$$\text{IQR} = 3.1$$

$$6\cdot \text{IQR}= 18.6$$

Observation 2 is clearly an outlier. My question is: What is the standard procedure for those values? In this particular case, should we use only the preceding value to replace the observation?

Edit: This is an "ex-post" discussion regarding the method described here to treat outliers, i.e. when it has already been decided to remove them. This is not a discussion about the nature of outliers or the drawbacks of replacing them.

• This is a (poor) variant of smoothing procedures used by John Tukey and described by him in detail in his 1977 book EDA. Tukey gives several methods to deal with smoothing the ends of a series. Little of this will apply to such a Procrustean, inflexible method of "outlier adjustment" (really a form of trimming).
– whuber
Commented Feb 23, 2023 at 15:23
• @whuber thank you for the reference, I will take a look. In your opinion, what could be a better procedure (or at least more detailed) for smoothing data for factor analysis? Commented Feb 23, 2023 at 15:29
• It depends on the type of data and the objective. Tukey's book, although dated (it focuses on procedures one can actually do with pencil and paper and says nothing about using computers), is still an excellent reference for the concepts and for methods to develop such procedures. In particular, it will help you appreciate the value of re-expressing (transforming) the data, of graphical exploration, and of iterating your analysis until an effective solution is reached.
– whuber
Commented Feb 23, 2023 at 15:31
• Unless the outlier is in fact wrong, replacing an outlier by anything else replaces a correct value by an incorrect one. I doubt that this will help much. (Smoothing is not the same as replacing observations.) Commented Feb 25, 2023 at 21:27
• Clicking on the paper title in your question gives me "page not found". Commented Feb 25, 2023 at 21:28