coin_win: Winsorisation helper function

Description Usage Arguments Details Value See Also Examples

View source: R/coin_treat.R

Description

To be used inside treat() to avoid repetitions. Winsorises a numerical vector of data.

Usage

1
2
3
4
5
6
7
8
coin_win(
  icol,
  winmax,
  winchange = TRUE,
  t_skew = 2,
  t_kurt = 3.5,
  icode = NULL
)

Arguments

icol

The vector of data to Winsorise

winmax

The maximum number of points to Winsorise for each indicator. If NA, will keep Winsorising until skewness and kurtosis thresholds achieved (but it is likely this will cause errors).

winchange

Logical: if TRUE, Winsorisation can change direction from one iteration to the next. Otherwise if FALSE (default), no change.

t_skew

Absolute skew threshold (default 2).

t_kurt

Kurtosis threshold (default 3.5).

icode

The indicator name - used for error messages in treat().

Details

Outliers are identified according to skewness and kurtosis thresholds. The algorithm attempts to reduce the absolute skew and kurtosis by successively Winsorising points up to a specified limit.

The process is detailed in the COINr online documentation.

Value

A list containing:

See Also

Examples

1
2
3
4
5
6
7
8
9
# get a column of data with outliers
x <- ASEMIndData$Tariff
# Winsorise up to five points
winlist <- coin_win(x, winmax = 5)
# check the differences
data.frame(
Orig = x,
Treated = winlist$icol,
Changes = ifelse(x == winlist$icol, "Same", "Treated"))

COINr documentation built on Nov. 30, 2021, 9:06 a.m.