business-science / anomalize

Tidy anomaly detection

Home Page:https://business-science.github.io/anomalize/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Critical Limits for IQR Method

cici7941 opened this issue · comments

For this code block to calculate the critical limits, I don't see a difference when there are outliers or not since limit_tbl$limit_lower and limit_tbl$limit_upper come from limits[1]) and limits[2] which are the same for each row.

  if (any(vals_tbl$outlier == "No")) {
    # Non outliers identified, pick first limit
    limit_tbl <- vals_tbl %>%
      dplyr::filter(outlier == "No") %>%
      dplyr::slice(1)
    limits_vec <- c(
      limit_lower = limit_tbl$limit_lower,
      limit_upper = limit_tbl$limit_upper
    )
  } else {
    # All outliers, pick last limits
    limit_tbl <- vals_tbl %>%
      dplyr::slice(n())
    limits_vec <- c(
      limit_lower = limit_tbl$limit_lower,
      limit_upper = limit_tbl$limit_upper
    )
  }```