Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to detect anomalous values in a time series of climatic data with some missing observations. Searching the web I found many available approaches. Of those, stl decomposition seems appealing, in the sense of removing trend and seasonal components and studying the remainder. Reading , stl appears to be flexible in determining the settings for assigning variability, unaffected by outliers and possible to apply despite missing values. However, trying to apply it in R, with four years of observations and defining all the parameters according to , I encounter error:

"time series contains internal NAs" (when na.action=na.omit), and
"series is not periodic or has less than two periods" (when na.action=na.exclude).

I have double checked that the frequency is correctly defined. I have seen relevant questions in blogs, but didn't find any suggestion that could solve this. Is it not possible to apply stl in a series with missing values? I am very reluctant to interpolate them, as I do not want to be introducing (and consequently detecting...) artifacts. For the same reason, I do not know how advisable it would be to use ARIMA approaches instead (and if missing values would still be a problem).

Please share if you know a way to apply stl in a series with missing values, or if you believe my choices are methodologically not sound, or if you have any better suggestion. I am quite new in the field and overwhelmed by the heaps of (seemingly...) relevant information.

share|improve this question
I'm having the same problem. STL method should be able to just fill in the missing values thru LOESS, but this R implementation does not seems to do so. – jf328 Apr 24 '13 at 12:11

ARIMA models easily incorporate dummy variables to deal with missing values. These are called Pulse Indicators . The methodology is straightforward and documented in In general the method extracts from the current residual series information regarding Pulses, Level Shifts, Seasonal Pulses and Local Time Trends.

share|improve this answer
thank you for the suggestion and the very interesting article! – effie Aug 22 '12 at 15:17

According to @Julius in this post is it possible to use stl with na.approx, from zoo package, using stl(x, na.action = na.approx, ...). This does some sort of interpolation.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.