Skip to content
Prev 41 / 523 Next

[RsR] [R] M-estimator R function question

Dear Kjell ,

beware of a minor error in the pairwise code that you posted: the
weights in gk.sigmamu() will never become 0, even if abs(x) > c1.

The correction should be:

gk.sigmamu <- function(x, c1 = 4.5, c2 = 3.0, mu.too = FALSE, ...)
{
  n <- length(x)
  medx <- median(x)
  sigma0 <- median(abs(x - medx))

  # VT::19.12.2005 - should give 0 weights if abs(x - medx) / sigma0 > c1
  #
  #  w <- (x - medx) / sigma0
  #  w <- (1.0 - (w / c1)^2)^2
  #  w[w < 0.0] <- 0.0

  w <- abs(x - medx) / sigma0
  w <- ifelse(w<=c1,(1.0 - (w / c1)^2)^2,0)

  # VT::19.12.2005 - END

  mu <- sum(x * w) / sum(w)
...... ... ... ..


best regard
valentin
On 12/5/05, Kjell Konis <konis at stats.ox.ac.uk> wrote: