I did coding in R as below,
data1<-c(25,35,60,79,50)
data2<-c(100,150,170,200,1000)
g1=sort(data1)
g2=sort(data2)
ybar1<-mean(g1)
ybar2<-mean(g2)
#BIWEIGHT
med1=median(g1)
med2=median(g2)
mad1=1.4826*(median(abs(g1-med1)))
mad2=1.4826*(median(abs(g2-med2)))
u1=(g1-med1)/(9*mad1)
u2=(g2-med2)/(9*mad2)
#cat("\nu1:",u1)
u=rbind(u1,u2)
print(u)
abs=abs(u)
print(abs)
for(j in abs){
if(j < 1){
num1 = ((g1-med1)^2)*((1-(u1^2))^4)
den1 = ((1-(u1^2))*(1-5*(u1^2)))
num2 = ((g2-med2)^2)*((1-(u2^2))^4)
den2 = ((1-(u2^2))*(1-5*(u2^2)))
}
}
cat("\num2:",num2)
but when i calculate manually, for data1, every value u1 is less than 1, thus the coding is right with my manual calculation, but for data2, it include value of u2 that is more than 1. can anyone help me figure out why it happen and how to fix it? thankyou in advance.
Aucun commentaire:
Enregistrer un commentaire