This sounds easy, but I don't know of a good statistical method for it.
I have a time series that has (good) data points that range from ~3.5 to 30. The data are collected by an automated sensor. However, there are flawed measurements in the time series-- the sensor will sometimes read values that are typically at exactly 4.7. Example (in R):
Data <- c(10.7, 4.7, 10.7, 4.7, 11.5, 4.7, 8.4, 4.7, 11.0, 4.7, 10.8, 4.7, 12.0, 10.3, 4.7, 10.4, 10.9, 4.7, 10.8, 4.7, 11.1, 4.7, 8.8, 4.7, 6.4, 4.7, 9.1, 4.7, 9.1, 4.7, 9.7, 4.7, 7.8, 4.7, 7.2, 4.7, 6.2, 4.7, 8.7, 4.7, 9.0, 4.7, 9.6, 4.7, 7.9, 4.7, 9.2,4.7, 8.1, 4.7, 7.4, 4.7, 7.6, 9.3, 4.7, 9.2, 4.7, 8.8, 4.7, 9.3, 4.7, 9.2, 4.7, 7.0, 4.7, 9.2, 4.7, 8.5, 4.7, 6.2,4.7, 7.1, 4.7, 7.4, 4.7, 8.0, 4.7, 7.3, 4.7, 6.6, 4.7, 6.9, 4.7, 7.2, 7.9, 4.7, 9.0, 4.7, 8.7, 4.7, 8.2, 4.7, 5.1,4.7, 5.6, 4.7, 7.0, 4.7, 9.4, 4.7, 7.6, 4.7, 8.6, 4.7, 9.3, 4.7, 9.7, 4.7, 10.4, 4.7, 10.6, 4.7, 10.9, 4.7, 10.2, 4.7, 10.0,4.7, 8.3, 10.0, 8.7, 4.7, 10.2, 9.7, 4.7, 10.2, 4.7, 10.6, 4.7, 10.5, 4.7, 9.7, 4.7, 10.6, 4.7, 10.6, 4.7, 11.6,4.7, 11.4, 4.7, 10.2, 4.7, 10.3, 4.7, 10.0, 4.7, 9.3, 4.7, 9.1, 4.7, 10.2, 4.7, 8.5, 4.7, 7.2, 4.7, 10.4, 4.7, 10.4, 10.0,4.7, 9.9, 4.7, 11.2, 9.5, 4.7, 11.5, 4.7, 11.5, 4.7, 11.1, 4.7, 11.4, 4.7, 12.0, 4.7, 11.4, 4.7, 11.2, 4.7, 9.9, 4.7, 11.6, 4.7, 14.4, 4.7, 11.5, 4.7, 11.1, 4.7, 11.3, 4.7, 10.9, 4.7, 11.1, 4.7, 11.1, 4.7, 10.9, 11.4, 4.7, 12.6, 4.7, 11.0, 11.3)
plot(1:length(test), test, type="o")
As you can see, almost every other point is 4.7. I don't want to simply use the rule of "throw out every value that is equal to 4.7" for two reasons: 1) sometimes there are real values that approach 4.7, which can become apparent as you see the slope of the time series change and enter the 4.7 region; 2) the "bad" values aren't always exactly 4.7 (they almost always are, but there is no guarantee).
This seems like a fairly simple problem, and I'm hoping that someone has heard of a statistical approach that would be suitiable for this problem. The desired outcome would be a time series where the "bad" values were statistically flagged (e.g., with a probability of being an error).
Suggestions? Thanks!
EDIT: I'm still mulling over the first two responses. My original inclination was to define two states of the system: an erroneous state and a measured state. The measured state would reflect a modeled process (e.g., AR). The erroneous state would reflect my knowledge that bad values tend to be near 4.7. Both states could ~N(), with appropriate means and sd's. At each time step I could calculate the likelihood of either state, and define a threshold ratio for declaring an obs erroneous. This is similar to the 2 answers. For this approach, I'm stuck at finding a way to let the model for the measured state make estimates w/o being influenced by bad values. However, as stated above, I'm still considering the other two approaches.