Outlier checks identify observations that sit far away from the usual values.

Program

Play the script to change the distance limit and see how many values are flagged.

outlier_flag.R
limit <- 
value <- c(42, 44, 43, 58)
center <- median(value)
distance <- abs(value - center)
flagged <- distance > limit
count <- sum(flagged)
label <- paste("outliers", count, sep = ":")
cat(label, "\n", sep = "")
limit <- 
value <- c(42, 44, 43, 58)
center <- median(value)
distance <- abs(value - center)
flagged <- distance > limit
count <- sum(flagged)
label <- paste("outliers", count, sep = ":")
cat(label, "\n", sep = "")
limit <- 
value <- c(42, 44, 43, 58)
center <- median(value)
distance <- abs(value - center)
flagged <- distance > limit
count <- sum(flagged)
label <- paste("outliers", count, sep = ":")
cat(label, "\n", sep = "")
center `median(value)` gives a robust center for the values.
distance `abs(value - center)` measures how far each value is from the center.
flag `distance > limit` marks unusually distant observations.