I'm attempting to weight a mean to make outliers less impactful. I know people use a median here often but am looking to try to make a mean that's rbust to outliers. That is the further an observation is from the mean the less weight it has. I'm sure this has been done before. In meta-analysis weighted least squares, or multilevel modeling, the less precision a study has the less weight it is given. So this thinking is similar.
Here I attempt to do this weighting in a convoluted way that I think works. I first calculate the standard scores for each observation. Take that absolute value and calculate the logit link to constrain to be between -1 and 1. I multiply everything by 2 and subtract 1 from it to get everything between 0 and 1. This means that things close to the mean are now a value of 0 and things fa from the mean approach 1. That's the opposite of what I want so I reverse score it (1 - i) and now I have weights. I then use the weighted mean function in R to calculate the eman using the weights. It seems logical to mean that I now have a mean that's robust against outliers. But I'm not a mathematician nor a statistician.
Here I attempt to do this weighting in a convoluted way that I think works. I first calculate the standard scores for each observation. Take that absolute value and calculate the logit link to constrain to be between -1 and 1. I multiply everything by 2 and subtract 1 from it to get everything between 0 and 1. This means that things close to the mean are now a value of 0 and things fa from the mean approach 1. That's the opposite of what I want so I reverse score it (1 - i) and now I have weights. I then use the weighted mean function in R to calculate the eman using the weights. It seems logical to mean that I now have a mean that's robust against outliers. But I'm not a mathematician nor a statistician.
Code:
n <- 50
x <- sample(1:5, n, T, c(.1, .1, .2, .2, .4))
mean(x)
z <- 1 - (((1 - (1/(1 + exp(abs(scale(x)))))) * 2) - 1)
weighted.mean(x, z)
barplot(table(x))
- Is this logical to achieve what I want?
- Poke holes in the thinking.
- Is there a better way?
- Additional thoughts folks have?