I have several years of sensor data (temperature and relative humidity) that records every 1/2 hour. When the sensor dies, it often starts throwing bad data mixed in with good data before it dies completely. When it dies completely, it reports an error code ( like -100).
I've been trying to come up with an automated method to flag (and fill) bad data. I found @RobHyndman's Simple algorithm for online outlier detection of a generic time series R code and got it working but it assumes a simple seasonal pattern. If I were more conversant with STL, I might be able to figure out how to use it to replace outliers with expected values.
I've also found some of his (and his student's) other work on complex seasonality and wish I had the time now to absorb it all. In the meantime, my guess is that someone like him could probably add a line or two or a loop to that tsoutliers function and it would do just what I need.
I have posted the data to a google drive folder.
There are three files. LOESS2.csv has time and temperature (all that is needed for the posted question). The sensor starts going bad on 1/3/2013. I've added a snippet below of the first obviously bad values. If you want the good the bad and the ugly - which might suggest a couple alternative approaches - check out the other files.
1/2/2013 23:00 18.08 1/2/2013 23:30 18.02 1/3/2013 0:00 17.92 1/3/2013 0:30 -9.66 1/3/2013 1:00 -17.56 1/3/2013 1:30 17.61 1/3/2013 2:00 17.43 1/3/2013 2:30 17.26
A characteristic of the data that might help is each value is actually an average of more frequent measurements by a data logger. Perhaps as a result, they are fairly smooth in that they rarely "reverse direction" twice in a short period.
After a night of thinking about this, I am wondering if I should try to get at this using TBATS (or even VARS) instead of STL.