@@ -161,8 +161,7 @@ detect_outlr <- function(x = seq_along(y), y,
161161# ' group_by(geo_value) %>%
162162# ' mutate(outlier_info = detect_outlr_rm(
163163# ' x = time_value, y = cases
164- # ' )) %>%
165- # ' unnest(outlier_info)
164+ # ' ))
166165detect_outlr_rm <- function (x = seq_along(y ), y , n = 21 ,
167166 log_transform = FALSE ,
168167 detect_negatives = FALSE ,
@@ -189,7 +188,7 @@ detect_outlr_rm <- function(x = seq_along(y), y, n = 21,
189188
190189 # Calculate lower and upper thresholds and replacement value
191190 z <- z %> %
192- epi_slide(fitted = median(y ), .window_size = n , .align = " center" ) %> %
191+ epi_slide(fitted = median(y , na.rm = TRUE ), .window_size = n , .align = " center" ) %> %
193192 dplyr :: mutate(resid = y - fitted ) %> %
194193 roll_iqr(
195194 n = n ,
@@ -256,9 +255,8 @@ detect_outlr_rm <- function(x = seq_along(y), y, n = 21,
256255# ' group_by(geo_value) %>%
257256# ' mutate(outlier_info = detect_outlr_stl(
258257# ' x = time_value, y = cases,
259- # ' seasonal_period = 7
260- # ' )) %>% # weekly seasonality for daily data
261- # ' unnest(outlier_info)
258+ # ' seasonal_period = 7 # weekly seasonality for daily data
259+ # ' ))
262260detect_outlr_stl <- function (x = seq_along(y ), y ,
263261 n_trend = 21 ,
264262 n_seasonal = 21 ,
@@ -359,7 +357,7 @@ roll_iqr <- function(z, n, detection_multiplier, min_radius,
359357
360358 z %> %
361359 epi_slide(
362- roll_iqr = stats :: IQR(resid ),
360+ roll_iqr = stats :: IQR(resid , na.rm = TRUE ),
363361 .window_size = n , .align = " center"
364362 ) %> %
365363 dplyr :: mutate(
0 commit comments