RobStatTM (version 1.0.2)

scaleM: M-scale estimator

Description

This function computes an M-scale, which is a robust scale (spread) estimator. M-estimators of scale are a robust alternative to the sample standard deviation. Given a vector of residuals r, the M-scale estimator s solves the non-linear equation mean(rho(r/s, cc))=b, where b and cc are user-chosen tuning constants. In this package the function rho is one of Tukey's bisquare family. The breakdown point of the estimator is min(b, 1-b), so the optimal choice for b is 0.5. To obtain a consistent estimator the constant cc should be chosen such that E(rho(Z, cc)) = b, where Z is a standard normal random variable.

Usage

scaleM(u, delta = 0.5, tuning.chi = 1.547645, family = "bisquare",
  max.it = 100, tol = 1e-06, tolerancezero = .Machine$double.eps)

Arguments

u

vector of residuals

delta

the right hand side of the M-scale equation

tuning.chi

the tuning object for the rho function as returned by lmrobdet.control, bisquare, mopt or opt. It should correspond to the family of rho functions specified in the argument family.

family

string specifying the name of the family of loss function to be used (current valid options are "bisquare", "opt" and "mopt").

max.it

maximum number of iterations allowed

tol

relative tolerance for convergence

tolerancezero

smallest (in absolute value) non-zero value accepted as a scale. Defaults to .Machine$double.eps

Value

The scale estimate value at the last iteration or at convergence.

Details

The iterative algorithm starts from the scaled median of the absolute values of the input vector, and then cycles through the equation s^2 = s^2 * mean(rho(r/s, cc)) / b.

Examples

Run this code
# NOT RUN {
set.seed(123)
r <- rnorm(150, sd=1.5)
mscale(r)
sd(r)
# 10% of outliers, sd of good points is 1.5
set.seed(123)
r2 <- c(rnorm(135, sd=1.5), rnorm(15, mean=-5, sd=.5))
mscale(r2)
sd(r2)

# }

Run the code above in your browser using DataLab