% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/utils.R
\name{is_outlier}
\alias{is_outlier}
\title{Detect outliers using MAD (Median Absolute Deviation)}
\usage{
is_outlier(
  x,
  nmads = 2.5,
  constant = 1.4826,
  type = c("both", "lower", "higher")
)
}
\arguments{
\item{x}{Numeric vector.}

\item{nmads}{Number of MADs from the median to define the boundaries for outliers.
Default is \code{2.5}.}

\item{constant}{Constant factor to convert the MAD to a standard deviation.
Default is \code{1.4826}, which is consistent with the MAD of a normal distribution.}

\item{type}{Type of outliers to detect.
Available options are \code{"both"}, \code{"lower"}, or \code{"higher"}.
If \code{type} is \code{"both"}, it detects both lower and higher outliers.
If \code{type} is \code{"lower"}, it detects only lower outliers.
If \code{type} is \code{"higher"}, it detects only higher outliers.}
}
\value{
Numeric vector of indices indicating the positions of outliers in \code{x}.
}
\description{
Detect outliers using MAD (Median Absolute Deviation)
}
\examples{
x <- c(1, 2, 3, 4, 5, 100)
is_outlier(x) # returns 6

x <- c(3, 4, 5, NA, 6, 7)
is_outlier(x, nmads = 1.5, type = "lower") # returns 4

x <- c(10, 20, NA, 15, 35)
is_outlier(x, nmads = 2, type = "higher") # returns 3, 5
}
