The method identifies spikes by statistical deviation from a
smoothed form of the series. The first step is to construct gapless, physically-realistic series
that has no missing values, and no values outside the physical range
(if physical.range is given). All such values are replaced
with the overall median.
The next step is to create a smoothed version of this series. If
method=1, a running median is used, calculated with
runmed, with the running length given by k. If
method=2, smooth is used.
Finally, the difference between this smoothed series and the gapless,
physically-realistic series is calculated. Any spots at which this
difference exceeds its mean value by n standard deviations are
flagged as spikes.