# Accounting for measurement bias using a histogram or violin plot and numerical data in R

The Problem

I have a gardener whose job it is to measure trees in meters using a measuring stick. She measures the heights of 1,000 trees. I plot these measurements on a violin plot in R. I am specifically interested in identifying trees that are growing too tall (above six meters) or too short (below 3 meters), so I added horizontal lines to the plot to show this graphically.

data <- round(rnorm(1000,4), 2)
library(vioplot)
vioplot(data, wex = 0.5, ylim = c(0, 7))
abline(a = 3, b = 0)
abline(a = 6, b = 0)


This is all well and good. However, my assumption is that the gardener incorrectly estimates the height of the trees some of the time. Specifically, sometimes she doesn't overestimate their size at all (change of 0), often she overestimates them by 0.3 meters, and occasionally she overestimates them by an entire meter (change of 1.0). I think, in the simplest case, I could "correct" her measurements like so:

vioplot(data, (data - 0.3), (data - 1.0), wex = 0.5, ylim = c(0, 7))


My question

I think it’s more complicated than that due to the fact that if the gardener shifts results by 0.0 to let’s say 1.0 (some results may be entirely correct, only a certain percent are shifted), it’s a random process that affects mostly trees in the center of the Gaussian curve. As we move higher from the mean, the number of shifted specimens decreases but it is still relatively high due to relatively high number of the high normal values. In order to shift an abnormally low tree into the normal range (between the horizontal lines), the gardener starts with considerably fewer trees, which makes it a considerably less likely (albeit possible) event. Does that make sense? So how would I account for this in my R code?

If I draw the lines in the same place, what proportion of trees will be missclassified??

• What is it you're trying to achieve, exactly? It's not completely clear what you need the outcome to be. – Glen_b Feb 23 '15 at 4:00
• Here's a kernel density estimate for a very large "sample" of trees (black), and for the gardener's estimates (green - 60% chance of adding nothing, 25% chance of adding 0.3 and 15% chance of adding 0.1). As you can see, it's a bit hard to discern much of anything in the picture even with a very large sample. What do you want to get from the gardener's estimates, exactly? – Glen_b Feb 23 '15 at 4:08
• Focus first on the statistical problem you want to solve. I don't think you comprehend that this may be a very subtle problem which you're going to have to provide more information on to have any real hope of solving. It's made doubly difficult if you're less than clear about what you want. Are you expecting to somehow identify which trees the gardener got wrong? Or something else? This is not simply a matter of shouting "Enhance!" at some guy at a computer and pushing a button and out comes some cleaned up image. What are the properties you want the result to have? – Glen_b Feb 23 '15 at 4:12
• @Glen_b Thanks for comments! I think what I want to do is what you have described in your second comment, i.e., transform the values but with a bit of chance thrown in. Do you know how I would include chance like that in R? – Alexander Feb 23 '15 at 12:12
• In your story the gardener doesn't classify trees at all. You do. Do you mean "If I draw the lines in the same place, what proportion of trees will be misclassified?"...? If that's what you want to know it would be good to state it explicitly in the question. That's a question that could potentially be answered in a relatively straightforward way, I think. Your current question says "I want to shift some of the values but not all" -- and even with your clarification, I don't know quite what that means (it still sounds like you're trying to identify mismeasured trees). What is it asking for? – Glen_b Feb 23 '15 at 14:01