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.
 A: One neat way to deal with the lack of predecessors for the first items in the list is to turn the list into a loop where the last items are effectively the predecessors of the first. That might make the procedure that you are looking at work equally well for all positions in the list, but it is not a procedure that should be adopted without careful consideration.
When dealing with outliers you need to think about what the outliers are and what they can tell you. The categories of outliers depend a lot on context, but a few general categories include mistakes (e.g. values recorded with a typo or an out of place decimal); spurious noise (e.g. where a value was recorded that had been affected by the laboratory door being slammed); plain noise; or something else. If the value is a mistake then fix it with reference to some reliable source (e.g. laboratory records) or discard it. If the value has spurious noise then treat it as a mistake. If the value is affected by ordinary noise then keep it, as it contains the informative signal and the noise that your statistical methods need to deal with. In effect, if the outlier is affected by ordinary noise then it is not an outlier in any sense beyond being at or near the edge of the data and it should not usually be trimmed or adjusted.
If you are dealing with lots of outliers in a dataset then it might be that the data are expressed in a form that makes real values appear to be outliers. It is very common in biomedical experimentation that the values are most nearly normal (or at least symmetrically distributed) when log-transformed.
When a dataset is deemed to contain an outlier that requires some adjustment, think about whether replacing it with a median or mean of the other values is a good plan or whether you should simply omit the outlier. Omission prevents the outlying value from influencing the results and also prevents you from obtaining or giving the impression of having more data-derived information than you actually have. Whatever you do with the outlier should be explicitly declared in the results section.
