Outliers with robust regression in R -


i using lmrob function in r using robustbase library robust regression. use as, rob_reg<-lmrob(y~0+.,dat,method="mm",control=a1). when want return summary use summary(rob_reg) , 1 thing robust regression identifying outliers in data. part of summary output give me following,

6508 observations c(49,55,58,77,104,105,106,107,128,134,147,153,...) outliers |weight| <= 1.4e-06 ( < 1.6e-06);

which list outliers, in case 6508 (i removed majority , replaced ...). need somehow these these outliers , remove them data. did before use summary(rob_reg)$rweights weights observations , remove observations weight less value in example above value 1.6e-06. know, there way list of outliers without first getting weights of observations?

this old post had need thought i'd share solution.

    #fit model     fit = lmrob(y ~ x, data)     #create model summary     fit.summary = summary(fit)      #extract outlier threshold weight summary      out.thresh = fit.summary$control$eps.outlier      #returns weights corresponding outliers     #names(out.liers) corresponds index of observation     out.liers = fit.summary$rweights[which(fit.summary$rweights <= out.thresh)]      #add true/false variable outlier original data matching row.names of original data names of list of outliers     data$outlier = rep(na, nrow(data))     for(i in 1:nrow(data)){       data$outlier[i] = ifelse(row.names(data[i] %in% names(out.liers), "true", "false")     } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -