remove_outliers: Remove outliers

Description Usage Arguments Details Examples

View source: R/outliers_to_missing.R

Description

remove_outliers removes pupil size outliers based on the median absolute deviation (MAD).

Usage

1
remove_outliers(x, pupil = NULL, constant = 10, log_file = NULL, type = NULL)

Arguments

x

A numeric vector containing the outlier data.

pupil

An optional numeric vector of pupil size measurements. If specified, the function will return a new vector of pupil sizes, but with outliers removed.

constant

An integer that raises or lowers the cutoff threshold.

Details

See Leys, Ley, Klein, Bernard, & Licata (2013) for details regarding why the MAD should be used.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
library(dplyr)
library(ggplot2)

# Example 1: Outlier removal based on pupil dilation speed
blink <- mutate(blink,
    pupil_left_d = dilation_speed(pupil_left, timestamp),
    pupil_right_d = dilation_speed(pupil_right, timestamp),
    pupil_left_clean = remove_outliers(pupil_left_d, pupil_left),
    pupil_right_clean = remove_outliers(pupil_right_d, pupil_right)
  )

ggplot(blink, aes(x = timestamp)) +
  geom_point(aes(y = pupil_left), color = "red") +
  geom_point(aes(y = pupil_left_clean))

WillemSleegers/eyepatch documentation built on Aug. 2, 2021, 8:39 a.m.