biweight_location: Biweight Location

View source: R/biweight_location.R

biweight_locationR Documentation

Biweight Location

Description

This function computes the biweight location, a robust measure of central tendency for a numeric vector. The biweight location is less sensitive to outliers than the sample mean.

Usage

biweight_location(
  x,
  loc = stats::median(x),
  c = 6,
  tol = 1e-06,
  max_iter = 50,
  drop.na = FALSE
)

Arguments

x

A numeric vector.

loc

Initial guess for the location (default: median of x).

c

A numeric value specifying the tuning constant for the biweight estimator (c = 6 by default).

tol

Convergence tolerance for the iterative computation (default: 1e-6).

max_iter

Maximum number of iterations (default: 50).

drop.na

A logical value indicating whether to remove missing values (NA) from the calculations. If TRUE (the default), missing values will be removed. If FALSE, missing values will be included in the calculations.

Value

The biweight location of x.

Author(s)

Christian L. Goueguel

References

  • Mosteller, F., and Tukey, J. W. (1977). Data Analysis and Regression: A Second Course in Statistics. Addison-Wesley, pp. 203-209.

Examples

# Example 1: Compute biweight location for a vector
x <- c(seq(1,100))
tibble::tibble(
mean = mean(x),
med = stats::median(x),
biloc = biweight_location(x)
)

# Example 2: Biweight location is robust to outliers
x <- c(seq(1,99), 1e3)  # An outlier at 1000
tibble::tibble(
mean = mean(x),
med = stats::median(x),
biloc = biweight_location(x)
)


ChristianGoueguel/specProc documentation built on Nov. 9, 2024, 3:23 p.m.