66# ' vignette](https://cmu-delphi.github.io/epiprocess/articles/outliers.html) for
77# ' examples.
88# '
9- # ' @param x Design points corresponding to the signal values `y`. Default is
10- # ' `seq_along(y)` (that is, equally-spaced points from 1 to the length of
11- # ' `y`).
12- # ' @param y Signal values.
9+ # ' @template x-y
1310# ' @param methods A tibble specifying the method(s) to use for outlier
1411# ' detection, with one row per method, and the following columns:
1512# ' * `method`: Either "rm" or "stl", or a custom function for outlier
2522# ' summarized results are calculated. Note that if the number of `methods`
2623# ' (number of rows) is odd, then "median" is equivalent to a majority vote for
2724# ' purposes of determining whether a given observation is an outlier.
28- # ' @return An tibble with number of rows equal to `length(y)` and columns giving
29- # ' the outlier detection thresholds and replacement values from each detection
30- # ' method.
25+ # ' @template detect-outlr-return
3126# '
3227# ' @details Each outlier detection method, one per row of the passed `methods`
3328# ' tibble, is a function that must take as its first two arguments `x` and
@@ -147,32 +142,14 @@ detect_outlr <- function(x = seq_along(y), y,
147142# ' Detects outliers based on a distance from the rolling median specified in
148143# ' terms of multiples of the rolling interquartile range (IQR).
149144# '
150- # ' @param x Design points corresponding to the signal values `y`. Default is
151- # ' `seq_along(y)` (that is, equally-spaced points from 1 to the length of
152- # ' `y`).
153- # ' @param y Signal values.
145+ # ' @template x-y
154146# ' @param n Number of time steps to use in the rolling window. Default is 21.
155147# ' This value is centrally aligned. When `n` is an odd number, the rolling
156148# ' window extends from `(n-1)/2` time steps before each design point to `(n-1)/2`
157149# ' time steps after. When `n` is even, then the rolling range extends from
158150# ' `n/2-1` time steps before to `n/2` time steps after.
159- # ' @param log_transform Should a log transform be applied before running outlier
160- # ' detection? Default is `FALSE`. If `TRUE`, and zeros are present, then the
161- # ' log transform will be padded by 1.
162- # ' @param detect_negatives Should negative values automatically count as
163- # ' outliers? Default is `FALSE`.
164- # ' @param detection_multiplier Value determining how far the outlier detection
165- # ' thresholds are from the rolling median, which are calculated as (rolling
166- # ' median) +/- (detection multiplier) * (rolling IQR). Default is 2.
167- # ' @param min_radius Minimum distance between rolling median and threshold, on
168- # ' transformed scale. Default is 0.
169- # ' @param replacement_multiplier Value determining how far the replacement
170- # ' values are from the rolling median. The replacement is the original value
171- # ' if it is within the detection thresholds, or otherwise it is rounded to the
172- # ' nearest (rolling median) +/- (replacement multiplier) * (rolling IQR).
173- # ' Default is 0.
174- # ' @return A tibble with number of rows equal to `length(y)`, and columns
175- # ' `lower`, `upper`, and `replacement`.
151+ # ' @template outlier-detection-options
152+ # ' @template detect-outlr-return
176153# '
177154# ' @export
178155# ' @examples
@@ -235,10 +212,7 @@ detect_outlr_rm <- function(x = seq_along(y), y, n = 21,
235212# '
236213# ' Detects outliers based on a seasonal-trend decomposition using LOESS (STL).
237214# '
238- # ' @param x Design points corresponding to the signal values `y`. Default is
239- # ' `seq_along(y)` (that is, equally-spaced points from 1 to the length of
240- # ' `y`).
241- # ' @param y Signal values.
215+ # ' @template x-y
242216# ' @param n_trend Number of time steps to use in the rolling window for trend.
243217# ' Default is 21.
244218# ' @param n_seasonal Number of time steps to use in the rolling window for
@@ -248,23 +222,8 @@ detect_outlr_rm <- function(x = seq_along(y), y, n = 21,
248222# ' @param seasonal_period Integer specifying period of seasonality. For example,
249223# ' for daily data, a period 7 means weekly seasonality. The default is `NULL`,
250224# ' meaning that no seasonal term will be included in the STL decomposition.
251- # ' @param log_transform Should a log transform be applied before running outlier
252- # ' detection? Default is `FALSE`. If `TRUE`, and zeros are present, then the
253- # ' log transform will be padded by 1.
254- # ' @param detect_negatives Should negative values automatically count as
255- # ' outliers? Default is `FALSE`.
256- # ' @param detection_multiplier Value determining how far the outlier detection
257- # ' thresholds are from the rolling median, which are calculated as (rolling
258- # ' median) +/- (detection multiplier) * (rolling IQR). Default is 2.
259- # ' @param min_radius Minimum distance between rolling median and threshold, on
260- # ' transformed scale. Default is 0.
261- # ' @param replacement_multiplier Value determining how far the replacement
262- # ' values are from the rolling median. The replacement is the original value
263- # ' if it is within the detection thresholds, or otherwise it is rounded to the
264- # ' nearest (rolling median) +/- (replacement multiplier) * (rolling IQR).
265- # ' Default is 0.
266- # ' @return A tibble with number of rows equal to `length(y)`, and columns
267- # ' `lower`, `upper`, and `replacement`.
225+ # ' @template outlier-detection-options
226+ # ' @template detect-outlr-return
268227# '
269228# ' @details The STL decomposition is computed using the `feasts` package. Once
270229# ' computed, the outlier detection method is analogous to the rolling median
0 commit comments