iqr_top_bottom_coding: IQR-Based Top/Bottom Coding for a Single Variable

View source: R/apply_iqr_top_bottom_coding.R

iqr_top_bottom_codingR Documentation

IQR-Based Top/Bottom Coding for a Single Variable

Description

Internal utility that applies top and/or bottom coding to a numeric vector using an IQR rule on the log() transformation.

Usage

iqr_top_bottom_coding(
  x,
  w = NULL,
  times = 3,
  type = c("type_4", "type_2"),
  one_sided = NULL
)

Arguments

x

Numeric vector. Variable to be top/bottom coded.

w

Optional numeric vector of weights.

times

Numeric. Multiplier for IQR to determine bounds (default is 3).

type

Character. Quantile estimation type, passed to compute_weighted_percentiles function (e.g., "type_4", "type_2").

one_sided

Character. "top", "bottom", or NULL (default) for two-sided coding.

Value

A numeric vector with values above or below the threshold replaced (on the original scale).

Examples

## Not run: 
data <- lissyrtools::lissyuse(data = "it16", vars = c("dhi"))
iqr_top_bottom_coding(data$it16h$dhi)
iqr_top_bottom_coding(data$it16h$dhi, data$it16h$hwgt, one_sided = "top")

## End(Not run)

JosepER/lissyrtools documentation built on June 12, 2025, 12:11 p.m.