einfsMM <- function(Y, MMloc, MMcov) { # empirical influences for MM-estimates + PCA estimates # -------------------------------------------------------------------- rhobiweight <- function(x,c) { # Computes Tukey's biweight rho function with constant c for all values in x hulp <- x^2/2 - x^4/(2*c^2) + x^6/(6*c^4) rho <- hulp*(abs(x)=c) return(rho) } # -------------------------------------------------------------------- rhobiweightder1 <- function(x,c) { # Computes Tukey's biweight psi function with constant c for all values in x hulp <- x - 2*x^3/(c^2) + x^5/(c^4) rho <- hulp*(abs(x) eps) & (iter < 100)) { c1.old <- c1 fc <- erho.bw(p, c1) - (c1^2 * r)/6 fcp <- erho.bw.p(p, c1) - (c1 * r)/3 c1 <- c1 - fc/fcp if(c1 < 0) c1 <- c1.old/2 crit <- abs(fc) iter <- iter + 1 } return(c1) } "erho.bw" <- function(p, c1) return(chi.int(p, # expectation of rho(d) under chi-squared p 2, c1)/2 - chi.int(p, 4, c1)/(2 * c1^2) + chi.int(p, 6, c1)/(6 * c1^4) + ( c1^2 * chi.int2(p, 0, c1))/6) "erho.bw.p" <- function(p, c1) return(chi.int.p(p, # derivative of erho.bw wrt c1 2, c1)/2 - chi.int.p(p, 4, c1)/(2 * c1^2) + (2 * chi.int(p, 4, c1))/(2 * c1^3) + chi.int.p(p, 6, c1)/(6 * c1^4) - (4 * chi.int(p, 6, c1))/( 6 * c1^5) + (c1^2 * chi.int2.p(p, 0, c1))/6 + (2 * c1 * chi.int2(p, 0, c1))/6) # -------------------------------------------------------------------- "sigma1.bw" <- function(p, c1) { # called by csolve.bw.MM() gamma1.1 <- chi.int(p,2,c1) - 6*chi.int(p,4,c1)/(c1^2) + 5*chi.int(p,6,c1)/(c1^4) gamma1.2 <- chi.int(p,2,c1) - 2*chi.int(p,4,c1)/(c1^2) + chi.int(p,6,c1)/(c1^4) gamma1 <- ( gamma1.1 + (p+1)*gamma1.2 ) / (p+2) sigma1.0 <- chi.int(p,4,c1) - 4*chi.int(p,6,c1)/(c1^2) + 6*chi.int(p,8,c1)/(c1^4) - 4*chi.int(p,10,c1)/(c1^6) + chi.int(p,12,c1)/(c1^8) return( sigma1.0 / (gamma1^2) * p/(p+2) ) } # -------------------------------------------------------------------- csolve.bw.MM <- function(p, eff) { # constant for second Tukey Biweight rho-function for MM, for fixed shape-efficiency maxit <- 1000 eps <- 10^(-8) diff <- 10^6 #ctest <- csolve.bw.asymp(p,.5) ctest <- -.4024 + 2.2539 * sqrt(p) # very precise approximation for c corresponding to 50% bdp iter <- 1 while ((diff>eps) & (iter