Suppose I have these vectors:
q1<-c(9,8,10,9,3,2,1,2,4,5)
q2<-c(9,7,8,6,5,4,8,7,8,9)
q3<-c(0,0,0,5,9,5,9,5,0,5)
I want to compute a weighted mean based on a weights vector like corvector
MMean<-colMeans(rbind(q1,q2,q3))
corvector<-c(cor(q1,MMean),cor(q2,MMean),cor(q3,MMean))
So I use the following command
weighted.mean(c(mean(q1),mean(q2),mean(q3)), corvector, na.rm = TRUE)
#5.709562
But the result is not equal to the direct computation as below
sum(c(mean(q1),mean(q2),mean(q3))*corvector)
#6.248393
How could I use weighted.mean appropriately? Can you explain how this command compute this value?