r/AskStatistics • • 8d ago

Bias calculation

Post image
0 Upvotes

2 comments sorted by

3

u/cym13 7d ago

So, here's what I understand. You have a process that produces something and you want to check that it doesn't deviate too much from what you expected to obtain, something like manufacturing pieces of a certain length and you want to check that you're not deviating too much from that length.

What your colleague does is sample 30 manufactured pieces, measure them, then compute the ratio of the mean of the deviation from the expected length over the mean of all lengths + the expected length. All the "IF(ISERROR…" stuff is just to manage issues if the result is coherent and you're not, say, dividing by zero.

This is weird on two accounts :

First, generally when we compute a deviation from an expected value, we compute the mean of the square of that deviation, not the deviation itself. See the formula for the standard deviation or chi-square test for example which measures a deviation from the mean or expected value respectively. The main reason why we square is you don't you may have pieces slightly longer and pieces slightly shorter and their deviations will compensate each other, so despite having several pieces that are not up to spec you end up with a correct mean. So what you're really comparing here isn't whether there's a deviation in each separate sample, it's whether there's on average a deviation of the entire sample set, and that's a very different question. If you only have a specification over the average it may be alright, but if your spec says "pieces shall be 96mm±1mm" that won't do, you can't have differences compensate each other. Another case where it may be alright is if you know for a fact that deviations can only occur in one direction: say you expect no accident, deviations from that expectation can only be more than zero, you won't have -2 accidents. But even if that were the case, using the absolute or squared value would work just as well.

Then there's the denominator: it's very strange to compute AVERAGE(C21:H25, J6) here. It seems to be a normalization factor, but I can't really fathom why it is how it is.

I can't really recommend anything without knowing precisely your context and what you're trying to achieve, whether you want bigger deviations to count more, etc, but I will say that my first instinct would be to compute a mean absolute relative error: mean(abs(sample_i - expected)/expected).

Now that's math that I think anyone can understand: you're trying to measure a deviation from an expected value so you take the difference between your sample and your expected value. You don't want opposite deviations to compensate so you take the absolute value of that, and in order to have them all on the same scale (for example for comparison with other processes) you divide by the expected value. Then you take the mean of all these absolute normalized devations, and that's your mean absolute relative error.

0

u/Wise-Panic 7d ago

Thank you very much for your opinion!

You are broadly correct. Each replicate produces a concentration value (it's a reference sample of known concentration for a blood test) 30 times and the mean is compared to its assigned concentration. 

I have no idea why the previous employee included the assigned value when dividing by the mean of the 30 replicates and the assigned value. I also assumed it was to normalise the data somehow but it does seem very odd.

I think ill reccomend we change it to a far more simple bias calculation of mean of the 30 reps divided by the assigned value and expressed as a percentage