# Moving average filter for outlier removal

I am using a moving average filter to smooth data for outlier removal. By changing the number of average points, I am getting different result.

My data are multi-dimensional feature vectors.

I applied the moving average to the entire matrix and then on individual variables.

They give different results.

So, how to choose/guess the number of points to average over and should it be applied on the entire matrix or on a one by one basis?

• One approach to choosing a smoothing parameter would be to optimize one-step-ahead prediction errors (such as sums of squares of one-step-ahead prediction errors). If you're trying to identify outliers, you'd want a different measure of prediction error - one reasonably robust to outliers (and then moving averages would seem an odd choice - why not something more robust to the outliers?) – Glen_b -Reinstate Monica Nov 2 '13 at 1:11