wmed: weighted median

View source: R/Regression.R

wmedR Documentation

weighted median

Description

wmed computes the weighted median for data vector y and weights w, i.e. it solves the optimization problem:

Usage

wmed(y, w, verbose = F, tol = 1e-07, iter_max = 2000)

Arguments

y

: (numeric) data given (real or complex)

w

: (nubmer) positive real-valued weights. Inputs need to be of same length

verbose:

(logical) true of false (default). Set as true if you wish to see convergence as iterations evolve

tol:

threshold for iteration in complex case
default = 1e-7

iter_max:

number of iterations in complex case
default = 2000

Details

beta = arg min_b SUM_i | y_i - b | * w_i

Value

beta: (numeric) weighted median

converged: (logical) flag of convergence (in the complex-valued data case)

iter: (numeric) the number of iterations (complex-valued case)

Examples

wmed(1:5, c(1,0,1,2,3))
wmed(1:5 +1i, c(1,0,1,2,3))


Mufabo/Rrobustsp documentation built on June 11, 2022, 10:41 p.m.