Chapter 2. Describing Data: Graphical
Unit 2.3. Visualizing statistical data
Some graph types used by statisticians are readily available in Excel. Others require some data manipulation to produce results equivalent to those available in Minitab. Alternatively, you can buy SPC XL, a statistical add-in for Excel. But I think discussing definitions of main graph types is more important than seeing them.
In the coordinate plane, we have two axes. $latex x$-values are put on the horizontal axis. $latex y$-values are put on the vertical axis. A point with coordinates $latex (x,y)$ is located at the intersection of two straight lines: one of them is drawn vertically through point $latex (x,0)$ (which is on the $latex x$-axis); the other is drawn horizontally through point $latex (0,y)$ (which is on the $latex y$-axis).
A graph is the best tool to visualize a functional relationship. The rough-and-tough approach to graphing a function $latex y=f(x)$ is to
- select several values of the argument $latex {x_1},\,...,\,{x_n}$,
- calculate the corresponding values of the function $latex {y_1}=f({x_1}),\,...,\,{y_n}=f({x_n})$,
- put the points $latex ({x_1},{y_1}),\,...,\,({x_n},{y_n})$ on the coordinate plane and
- draw a smooth line through these points.
If you have never done this, do it at least once, say, for $latex y=2{x^2}+1$.
Keep in mind the terminology introduced here: $latex x$ is the argument, $latex f(x)$ is the value. The set of all arguments of the given function is called its domain. The set of all values is called its range. As the argument runs over the domain, the value runs over the range.
When working with functions, it's better to use words that emphasize motion. The notion of a function is one of the channels through which motion is introduced in mathematics.
The argument is also called an independent variable while the value (a dependent variable). It is customary to plot the dependent variable on the $latex y$-axis and the independent one on the $latex x$-axis, the most notable exceptions being the plots of demand and supply in economics.
To be confident with statistical graphs, you have to be clear about what is the argument and what is the value in each case. The short way to express this is: plot this ... (values) against that ... (arguments).
Histogram
Histogram (short definition). Plot frequencies against values.
Explanations.
(i) In case of numerical values, put them on the $latex x$-axis. Atop each of them show the corresponding frequency with a vertical bar whose height is equal to the frequency. The width of the bar doesn't matter, as long as the bars have the same widths and don't overlap. You can use either absolute or relative frequencies. I prefer relative frequencies and from now on talk only about them.
(ii) When values are intervals, we know from Exercise 2.4 (see Frequencies and distributions) that intervals of type Eq. (2.3) are adjacent. Bars showing frequencies are plotted against centers of the intervals. Regarding the heights and widths of the bars there are two possibilities:
- (a) The heights express frequencies. The widths don't matter as long as the bars don't overlap.
- (b) The areas of the bars are equal to frequencies. In this case the widths are equal to the lengths of the intervals on the $latex x$-axis (the bars stand shoulder to shoulder) and the heights are calculated from the usual area rule area = height $latex \times$ width.
The second possibility is used when, as in our case, the sample is obtained from a continuous variable. As we'll see in Unit 6.2, for a continuous variable there is an equivalent of relative frequencies, and that equivalent hinges upon area rather than height.
(iii) Suppose the values are categories other than ranges of numerical values, like instructor ranks. You put them on the $latex x$-axis at arbitrary points and plot the bars as in case (i).
Pareto diagram
Pareto diagram. Same as a histogram, except that the observations are put in the order of decreasing frequencies.
Example. In this case it is important to remember the motivation. Suppose there are too many traffic jams in the city and the mayor is determined to eliminate them. Among the reasons of traffic jams there are: lack of parking space in the center of the city, car accidents, absence of car junctions in critical areas, rush hours etc. It makes sense to start dealing with problems that have the highest impact on traffic jams frequency. Such problems (categories) on the histogram should be put first.
Time series plot
Time series plot. In a time series plot we plot values against time.
Example. A time series is a sequence of observations on a variable along time. For example, a sequence of daily observations on Microsoft stock can be written as $latex {s_1},...,{s_n}$. The observations are plotted in their raw form, without calculating any frequencies. We model them in Excel as follows. In D1 type Stock and in D2 enter the formula =NORMINV(RAND(),25,8). Copy it to cells D3-D21 (which corresponds to $latex n=20$). Select column D and "Line" in Insert/Line for the plot type. When you press F9, you see various realizations of the time series. Time series plots are good to see if there are any tendencies or trends in a series and how volatile it is. Financial time series are among the most volatile.
Stem-and-leaf display
Stem-and-leaf display. It is a tabular representation of the data where the observations are grouped according to their leading digits and the final digits (remainders) are used to show frequencies in each group. In Example 2.3 below we take the integer part (the number before the decimal point) as the stem (leading digits) and the digit after the decimal point as the leaf (final digits). The definitions of the stem and leaves depend on the data.
Firstly, this is not a graphical display. Secondly, going from the usual decimal representation to the stem-and-leaf display and back is drudgery. Given its very limited use in statistical data processing and availability of computers, having students do it by hand is a stone age.
Table 2.4. Stem-and-leaf display.
| Cumulative frequencies | Stem | Leaf |
|---|---|---|
| 2 | 9 | 2, 8 |
| 5 | 10 | 1, 2, 5 |
| 7 | 11 | 1, 7 |
| 7 | 12 | |
| 3 | 13 | 2 |
| 2 | 14 | 5 |
| 1 | 15 | 0 |
Example 2.3. Let's say we have a sample of lengths of 10 fish:
$latex {x_1}=9.8,\ {x_2}=10.1,\ {x_3}=14.5,\ {x_4}=10.5,\ {x_5}=13.2,$
$latex {x_6}=11.1,\ {x_7}=9.2,\ {x_8}=11.7,\ {x_9}=15.0,\ {x_{10}}=10.2.$
The lengths $latex {x_2}=10.1,\ {x_4}=10.5,\ {x_{10}}=10.2$ fall into one group. The stems are shown in the second column of Table 2.4 and the leaves in the third column. The first column contains cumulative frequencies. To obtain them, you start counting the absolute frequencies from the upper and lower ends until the cumulative frequencies are about the same (in the middle). The cumulative frequency in the first row is the absolute frequency in that row; the cumulative frequency in the second row is the sum of absolute frequencies in that row and the preceding row. You go like that and stop at row 4 because if you count similarly the cumulative frequencies starting from the bottom, in row 5 you will have 8.
Note three features of this display.
- The stems are ordered, unlike the original data.
- The number of leaves readily shows absolute frequencies in each group.
- You can restore the original values from this display if you know how much one unit in the stem is worth. In our example it is worth $latex w=1$ so, for example, the first line gives two values $latex 9\cdot w+2\cdot w\cdot 0.1=9+0.2=9.2,\ \ 9\cdot w+8\cdot w\cdot 0.1=9+0.8=9.8.$
- If we considered young fish, instead of 9.2 and 9.8 we could have 0.92 and 0.98 and each unit in the stem would have been worth $latex w=0.1$. The above calculation would have given the right values.
Scatterplot
Scatterplot. Plot values of one variable against values of another.
Be alert when you see a discussion of pairs of variables. Most students find this topic difficult.
Exercise 2.5. We want to see a rough dependence between the weight and height of an adult. For a sample of $latex n$ adults we write down their weights $latex {w_1},\,...,\,{w_n}$ and heights $latex {h_1},\,...,\,{h_n}$. The first thing to note is that these observations should be written in pairs because it doesn't make sense to link one person's weight with another person's height. The second thing is that, logically, it is the height that determines the weight and not the other way around. Therefore the right way to write the observations is
$latex ({h_1},{w_1}),\,...,\,({h_n},{w_n}). \qquad (\textrm{Eq. 2.4})$
A scatterplot just shows these points on the coordinate plane. Now we proceed with simulating them.
- In cell E1 type
Heightsand in cell E2 put the formula=NORMINV(RAND(),170,30)(heights are measured in centimeters and weights in kilos). In cell F1 typeWeightsand in cell F2 put the formula=E2-100+NORMINV(RAND(),0,20).- Select cells E2, F2 and by pulling down the small square in the lower right corner of cell F2 copy the contents of E2, F2 to sufficiently many cells.
- Select columns E, F and use "Insert/Scatter/Scatter with only Markers" (without lines connecting the points) to see the scatterplot.
You can see on the plot that there is, on average, a positive relationship between weight and height, as expected. If you press F9, the sample and plot will change.
Previous: Frequencies and distributions | Next: Questions for repetition (Chapter 2)
Want the whole book (all 14 chapters, exercises, and the index) as a single PDF? Available on Lulu for $1.99.
Leave a Reply
You must be logged in to post a comment.