RobustMFit.jl

Methods to estimate parameters of a distribution robustly
Author ManuelStapper
Popularity
2 Stars
Updated Last
6 Months Ago
Started In
August 2022

RobustMFit.jl

Build status codecov DOI

A Julia package to estimate parameters of a univariate distribution robustly by M-estimation. Currently implemented are Tukey, Huber, Andrew and Hampel functions as well as smoothed versions of the latter three. User-defined functions can be added using the NewMFunction.jl template.

Different estimation approaches are implemented:

Function types

Estimation can be carried out by minimizing a loss function (ρ-type), finding the root of its derivative (ψ-type) or iteratively by a weight function (w-type).

Method of Moments

The parameters can be estimated either directly or by estimating the raw moments of the distribution and translating them to parameters.

Bias Correction

Estimation is only unbiased in general if the underlying distribution is symmetric. A potential bias must also be taken into account for symmetric distributions with multiple parameters. Esimating for example the mean of a Normal distribution with symmetric (ρ, ψ or w)-function is unproblematic, but estimating the variance parameter is not, since the distribution of $X^2$ is asymmetric.

The bias can be tackled by a correction term in the $\psi$ estimation or by using asymmetric (ρ, ψ or w)-functions. For asymmetric functions, different tuning constants are selected for positive and negative input. One of those is kept constant while the other is chosen such that the estimator is consistent.

Examples

d = Poisson(10)
x = rand(d, 100)

# For ρ-Esimation, Moment based and updating lower tuning constant
λ = Mfit(x, d, Huber(1.5), type=, MM=true, biasCorr=:L)

# ψ-Estimation, estimate parameters directly, update upper tuning constant
Mfit(x, d, Tukey(4), type = , MM = false, biasCorr = :U)
# w-Estimation, Moment based, not accounting for asymmetry at all
Mfit(x, d, Tukey(4), type = , MM = false, biasCorr = :N)
# Or the same, but accounting for it with correction term
Mfit(x, d, Tukey(4), type = , MM = false, biasCorr = :C)

# Computing the asymptotic variance of the first estimation
AVar(Poisson(λ), Huber(1.5), :L)
# Or estimating it using the sample
AVar(x, Poisso(λ), Huber(1.5), :L)

# Comparing the robust estaimtion with ML estimation by relative asymptotic efficiency
RAE(Poisson(λ), Huber(1.5), :L)