epi_stats_count_outliers: Count univariate outliers

View source: R/epi_stats_count_outliers.R

epi_stats_count_outliersR Documentation

Count univariate outliers

Description

epi_stat_count_outliers() counts how many outliers a vector has using a univariate approach. Returns the number of observations that are greater than the cutoff. Outliers are detected with the Tukey method (above and below coef * IQR).

Usage

epi_stats_count_outliers(num_vec = NULL, coef = 1.5, ...)

Arguments

num_vec

Numeric vector to test.

coef

Coefficient for outlier detection, default is 1.5

...

Other parameters that can be passed to boxplot.stats().

Value

Returns the number of observations above the cut-off specified.

Note

coef = 0 returns no outliers, see ?boxplot.stats An alternative, not implemented, is to consider those eg > 5 * SD

Author(s)

Antonio J Berlanga-Taylor <\url{https://github.com/AntonioJBT/episcout}>

See Also

boxplot.stats

Examples


## Not run: 
n <- 1000
df <- data.frame(var_id = rep(1:(n / 2), each = 2),
                var_to_rep = rep(c("Pre", "Post"), n / 2),
                x = rnorm(n),
                y = rbinom(n, 1, 0.50),
                z = rpois(n, 2)
               )
epi_head_and_tail(df)
epi_stat_count_outliers(num_vec = df$x, coef = 0)
epi_stat_count_outliers(num_vec = df$x)
summary(df$x)


## End(Not run)


AntonioJBT/episcout documentation built on Dec. 1, 2024, 4:07 a.m.