# Using scatter plots to understand multiple values of Y for a given X

As I understand it, a scatter plot can contain multiple data points with the same independent variable value, and different values for the dependent variable. For example, if the horizontal axis represents height and the vertical represents weight, you could measure/weigh a group of people and you might observe several people at a particular height whose weights differed. On the resulting plot, those people would produce multiple data points directly above/below each other.

Coming from a math background, I've gotten used to mostly graphing 1-to-1 functions where this doesn't occur, so it kinda jumped out at me and I wanted to make sure I'm understanding it correctly. It seems like a powerful way to visualize probability distributions, but I haven't managed to find any explicit mention of such (probably because I don't know where to look). This seems like a good place to ask!

Sorry about the non-specific title. I couldn't figure out how to sum up my question concisely.

Your discussion is correct. Imagine a set of heights and weights measured with a lot of precision (this is made up data to illustrate a point -- it really won't be like a set of real heights and weights - but notionally these are cm and kg)

There are two common ways to look at such a plot (usually in slightly different situations, but sometimes just as different ways of looking at the same data).

The first is simply to consider the bivariate distribution of which the sample (in some circumstances) might represent a randomly drawn set of bivariate observations. Specifically, the points will be more dense in regions where the bivariate density is higher. You will be able to think about the association between the variables (such as the fact that height and weight tend to increase together).

The other way is to consider the distribution of the $y$-variable conditional on the $x$-variable. (Excuse me, I'm going to be a little loose with notation to avoid obscuring the central ideas.)

If you had many people at each height, you could consider the distribution at each height. If the distributions at different $x$'s are similar apart from the mean (say), then this view could be thought of as regarding the distribution in terms of the way the means move: $m(x) = E(y|x)$, and then the distribution about the mean at given $x$ values (the distribution of $e = y - m(x)$, which will have characteristics that don't depend on $x$).

Note that $m(x) = E(y|x)$ is of the functional form you're used to thinking about.

(More generally, of course, the distribution around isn't so nicely behaved and does vary with $x$, but in many situations it's a reasonable description.)

If you don't have many at each height, you can convey a similar concept by thinking in terms of not an exact $x$, but the distribution of $y$ in a narrow strip of $x$-values, to approximate the distribution in the center of the strip.

This concept can either be conceived over a set of non-overlapping strips, or in a window that is moving across the range of $x$ (where there is overlap).

(Where $E[y|x]$ was assumed to progress linearly, we would be talking about linear regression models, at least as a general concept.)

In this discussion I have slipped back and forth between sample and population concepts, and I have done things like talk about expectations while illustrating it with what is notionally a sample mean. Hopefully the distinction between sample and population quantities remains clear enough in spite of the way I've not tried to keep them apart.

• Nice job on the graphs. People might benefit from seeing your code. – rolando2 Feb 17 '13 at 12:52
• It would probably be a good idea; unfortunately I am not going to be near that machine again for a while - I didn't think anything of it at the time. I could try to reconstruct it or something close to it if someone really wants it. – Glen_b Feb 17 '13 at 13:03

It's OK if the values are above/below each other. The purpose of the scatterplot is to visualize the spread of data. The concept behind typical xy-(Cartesian) plot in maths was to plot the function.

Yes, what you are describing is correct. The values can end up directly adjacent along one axis if the value they have on the other axis is exactly the same. This actually can pose a problem when you have individuals with identical scores on both axes as you only get one point of data visualization for multiple individuals. The solution to this issue is to use heat maps or to 'jitter', that is deliberately add some error to, the values on one or both axes.