Chapter 6: Graphics
Total Page:16
File Type:pdf, Size:1020Kb
Chapter 6 Graphics Modern computers with high resolution displays and graphic printers have rev- olutionized the visual display of information in fields ranging from computer- aided design, through flow dynamics, to the spatiotemporal attributes of infec- tious diseases. The impact on statistics is just being felt. Whole books have been written on statistical graphics and their contents are quite heterogeneous– simple how-to-do it texts (e.g., ?; ?), reference works (e.g., Murrell, 2006) and generic treatment of the principles of graphic presentation (e.g., ?). There is even a web site devoted to learning statistics through visualization http: //www.seeingstatistics.com/.Hence,itisnotpossibletobecomprehensive in this chapter. Instead, I focus on the types of graphics used most often in neu- roscience (e.g., plots of means) and avoid those seldom used in the field (e.g., pie charts, geographical maps). The here are four major purposes for statistical graphics. First, they are used to examine and screen data to check for abnormalities and to assess the distributions of the variables. Second, graphics are very useful aid to exploratory data analysis (??). Exploratory data analysis, however, is used for mining large data sets mostly for the purpose of hypothesis generation and modification, so that use of graphics will not be discussed here. Third, graphics can be used to assess both the assumptions and the validity of a statistical model applied to data. Finally, graphics are used to present data to others. The third of these purposes will be discussed in the appropriate sections on the statistics. This chapter deals with the first and last purposes–examining data and presenting results. 6.1 Examining data with graphics The main purpose here is to view the data to detect outliers and to make decisions about transforming variables. If the design has groups (even ordered groups), then your plots should be constructed separately for each group. It is possible for an outlier in one group to be hidden by the data points for other 1 CHAPTER 6. GRAPHICS 2 Figure 6.1: Examples of histograms: IQ scores from patients in a pediatric neurology clinic. 7 6 20 5 15 4 3 10 Frequency Frequency 2 5 1 0 0 40 50 60 70 80 90 100 50 60 70 80 90 100 IQ IQ groups. 6.1.1 Histograms In the past, teachers of statistics tortured undergraduate students by giving them a data set and requiring them to draw a histogram on graph paper. With access to graphing software, those days are over (mostly). The histogram groups anumericvariableinto“bins”andthenplotsthemidpointofthebinonthe horizontal axis the frequency of scores within the that bin on the vertical axis. The frequency can be expressed as either the raw number of scores or the percent of scores in the bin. In general, histograms are best used for relatively large sample sizes. The most significant decision for the user is the number of bins. When the number is too small, information is effectively “hidden.” When the number is too large, the histogram may have only one or two observations per bar and provides little information about the distribution. Also, bin size is a function of sample size. Smaller bins can be used with larger samples. Good statistical and graphing software usually gives a reasonable default size for the bins based on sample size. All software will give the use the option of specifying either the bin size (i.e., width of the bar) or the number of bins. Figure 6.1 gives histograms of the IQ scores of 63 children seen at a pediatric neurology clinic. The left hand plot in Figure 6.1 was generated using a default for the number of bins . The right hand plot specified 25 bins. Note that histograms result in a “wide” plot for a variable. Also, the range of the horizontal axis is often determined by the software. Hence, comparing groups using histograms can require extra work and the resulting graphic may CHAPTER 6. GRAPHICS 3 Table 6.1: R code for producing a dot p[lot (strip chart). stripchart(pkcgamma$open_arm ~ pkcgamma$genotype, method="j i t t e r " , vertical=TRUE, ylab="Percent Time in Open Arm", xlab="Genotype", col="blue", pch=1, cex=1.5) not be easy to interpret. There are fancy routines that that will plot histograms for two (sometimes three) groups using “transparent” color schemes, but the simplest way to examine groups is through dot plots and/or box plots. 6.1.2 Dot plots (strip charts) A“dotplot”meansdifferentthingstodifferentstatisticalpackages.Here,the term is used in its traditional sense (?) and encompasses what R calls a “strip chart.” Dot plots can be one of the most useful ways of displaying and perusing data for neuroscience because sample sizes are usually small to moderate. The type of dot plot most useful in neuroscience has the groups on the hori- zontal axis and the values for the variable on the vertical axis. Each observation then becomes a point in the graph, plotted by its value. Figure 6.2 gives two examples for the PKC-γ data. The left hand panel gives the traditional dot plot. In the right hand panel, the points are “jittered” or moved slightly to the left or right in order to avoid overlapping points. Table 6.1 presents the R code for these plots. This code produced the right-hand or “jittered” figure. To produce the left-hand figure omit the argument method=”jitter” . The advantages of a dot plot are: (1) every value in the data can be visually inspected; (2) the range of the data for each group is apparent in the event that there may be significant differences in variance; and (3) outliers can be readily identified. The major disadvantage comes when data sets are so large that overlapping points make it difficult to appreciate the distribution of scores (although some graphical software can overcome this limitation with moderately sized data sets). A second disadvantage is that the dot plot does not give information about the statistics of a distribution. CHAPTER 6. GRAPHICS 4 Figure 6.2: Example of a dot plot. ● ● 30 ● 30 ● ● ● ● ●● ● ● ● ● ● ● ● ● 20 ● 20 ● ● ● ● ● ● ●● ● ● ● ●● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● 10 ● ● 10 ● ● ● ● ● ● ●●● ● ● ● ● ●● ● Percent Time in Open Arm Percent ● Time in Open Arm Percent ● ● ● ● ● ● ● ● ● 0 ● ● 0 ● ● ● ● ++ +− −− ++ +− −− Genotype Genotype 6.1.3 Box (and whisker) plot Figure 6.3 provides a box plot (aka box-and-whisker plot) of the same data. In this plot, individual data points are not identified. Instead the shape of the distribution is visually portrayed through the shape of a box and arms (or whiskers). The bottom arm begins with the lowest connected data point in the series (we postpone the definition of a connected data point for the moment). The lower part of the box starts with the score at the first quartile and upper part ends with the score at the third quartile. The horizontal line close to the middle of the box is the median. Finally, the upper “whisker” starts above the third quartile and ends with the uppermost connected data point. Hence, the size of the box gives the interquartile range of the data, i.e., the 25th through the 75th percentiles. Box plots are more useful than dot plots when there is a moderate to large number of observations per group. Their symmetry permits one to assess skew- ness and they are very helpful in detecting outliers. In symmetrical distributions, the median splits the box into equal halves and two whiskers are of equal length. A distribution with a positive skew (see the right hand box plot in Figure 6.4) has a short whisker at the bottom, a median that is located below the half way point in the box, a long whisker at the top, and a number of unconnected data points at the high end. A variable with a negative skew has the opposite shape—short whisker at the top, a median above the half way point in the box, a long whisker at the bottom, and a number of unconnected data points at the low end (see Figure 6.4). CHAPTER 6. GRAPHICS 5 Figure 6.3: Box plots for the PKC-γ data by genotype. 30 ● 20 10 Percent Time in Open Arm 0 ++ +− −− Genotype 6.1.3.1 Unconnected data points Most graphing software offers two options for dealing with very high and very low values. The first option is to plot them as unconnected data points above and below the whiskers. This was the option used to generate Figures 6.3 and 6.4. The second option is extend the whiskers to the lowest and to the highest values. There are no formal criteria defining an unconnected data point. Hence, it is always necessary to consult the manual for the software. Many programs define an unconnected data point as a value lower than 1.5 times the interquartile range below the first quartile. For example, if the first quartile is at 31.4 and the third quartile is at 42.7, then the interquartile range is 42.7 – 31.4 = 11.3. Hence the cut offfor a lower unconnected data point would be 31.4 – 1.5*11.3 =14.45.Asimilarcriterionisusedforaunconnecteddatapointatthehigher end of the distribution. One cautionary note is in order—never consider an “unconnected” data point an outlier without further evidence. An unconnected data point may achieve its status simply because sample size is not large and the interquartile range for a group is small. This is precisely the case for the heterozygote’s box plot in Figure 6.3. Examination of the highest value for genotype +- in the dot plot of Figure 6.2 reveals that it belongs to the rest of the distribution.