R/opregMC.R

opregMC <-
function(x,y,regfun=tsregMC,cop=3,fast=FALSE,pr=TRUE,prres=FALSE,STAND=TRUE){
#
# Do regression on points not labled outliers
# using projection-type outlier detection method
#
library(parallel)
x<-as.matrix(x)
m<-cbind(x,y)
m<-elimna(m) # eliminate any rows with missing data
ivec<-outproMC(m,plotit=FALSE,cop=cop,fast=FALSE,pr=FALSE,STAND=STAND)$keep
np1<-ncol(x)+1
coef<-regfun(m[ivec,1:ncol(x)],m[ivec,np1])$coef
vec<-rep(1,length(y))
residuals<-y-cbind(vec,x)%*%coef
if(fast && pr){
print("Intercept, followed by slopes:")
print(coef)
if(prres){
print("Residuals:")
print(residuals)
}}
list(coef=coef,residuals=residuals)
}
musto101/wilcox_R documentation built on May 23, 2019, 10:52 a.m.