What is the canonical example which show situation when robust linear regression has advantage over least square linear regression ? I was trying to simulate situation when some errors (20% of them) are generated from t-student distribution and 80% are from normal - both distribution with the same variance ! on datasets with 50 observation, and I cant see clearly that robust regression is better, here is my R code for this experiment :
library(MASS)
n=50 # size of datasets
N=1000 # number of regressions
wynik=matrix(0,N,2) # matrix with estimated coefficients
v=5 # parametr of t-student distribution
Sd=(v/(v-2))^.5 # standard deviation of gaussian distribution
a=1 # coefficient
for(i in 1:N){
x=rnorm(n,mean=1,sd=Sd)
e_norm<-rnorm(n,sd=Sd)
e_t<-rt(10, df=v )
y_norm=a*x+e_norm
y_t=a*x+c(e_t,rnorm(40,sd=Sd)) # wariant 2 część to outliery
Zm1=lm(y_t~x)$coef[2]
Zm2=rlm(y_t~x)$coef[2]
wynik[i,1]=Zm1
wynik[i,2]=Zm2
plot(1,1,main=paste(i))
}
plot(density(wynik[,1]),main="density of LS estimator(black) and robust estimator (green)")
lines(density(wynik[,2]),col="green")
# average values of LS and robust estimator
colMeans(wynik)