hai_winsorized_move_vec: Vector Function Winsorize Move

View source: R/vec-hai-winsorized-move.R

hai_winsorized_move_vecR Documentation

Vector Function Winsorize Move

Description

Takes a numeric vector and will return a vector of winsorized values.

Usage

hai_winsorized_move_vec(.x, .multiple = 3)

Arguments

.x

A numeric vector

.multiple

A positive number indicating how many times the the zero center mean absolute deviation should be multiplied by for the scaling parameter.

Details

Takes a numeric vector and will return a winsorized vector of values that have been moved some multiple from the mean absolute deviation zero center of some vector. The intent of winsorization is to limit the effect of extreme values.

Value

A numeric vector

Author(s)

Steven P. Sanderson II, MPH

See Also

https://en.wikipedia.org/wiki/Winsorizing

This function can be used on it's own. It is also the basis for the function hai_winsorized_move_augment().

Other Vector Function: hai_fourier_discrete_vec(), hai_fourier_vec(), hai_hyperbolic_vec(), hai_kurtosis_vec(), hai_scale_zero_one_vec(), hai_scale_zscore_vec(), hai_skewness_vec(), hai_winsorized_truncate_vec()

Examples

suppressPackageStartupMessages(library(dplyr))

len_out <- 25
by_unit <- "month"
start_date <- as.Date("2021-01-01")

data_tbl <- tibble(
  date_col = seq.Date(from = start_date, length.out = len_out, by = by_unit),
  a = rnorm(len_out),
  b = runif(len_out)
)

vec_1 <- hai_winsorized_move_vec(data_tbl$a, .multiple = 1)

plot(data_tbl$a)
lines(data_tbl$a)
lines(vec_1, col = "blue")


healthyR.ai documentation built on April 3, 2023, 5:24 p.m.