donderdag 15 mei 2014

2.3.2. Median

What is it?

The median is defined as: “an order statistic that gives the "middle" value of a sample. More specifically, it is the value such that an equal number of samples are less than and greater than the value (for an odd sample size), or the average of the two central values (for an even sample size).” (Weisstein, n.d.-a). So it's simply the item/value in the middle after the items have been ordered.

If there is an even number of items, the average of the two items in the middle will be the median.

The median tells us that at least 50% of the values were higher or equal to the median, and alternatively at least 50% was lower or equal.


Figure 19 shows a visualisation for the median.


Figure 19. Visualisation of the median.

Different authors use different symbols for the median. For example McClave, Benson & Sincich (2005) use simply m, Bowerman, O'Connell & Murphee (2009) use Md, Steinberg (2010) uses Mdn, and Johnson & Kuby (2011) use the symbol also used in the above definition .

Examples

Example 1
On a survey ten people were asked to rate the design of the product on a scale of Very nice, Nice, Ugly, Very Ugly. The responses the researcher got were: Very Nice, Nice, Nice, Nice, Nice, Ugly, Ugly, Ugly, Very ugly, Very ugly. The responses are already in order. Crossing them out side by side gives:

Very Nice, Nice, Nice, Nice, Nice, Ugly, Ugly, Ugly, Very ugly, Very ugly
Very Nice
, Nice, Nice, Nice, Nice, Ugly, Ugly, Ugly, Very ugly, Very ugly
Very Nice, Nice, Nice, Nice, Nice, Ugly, Ugly, Ugly, Very ugly, Very ugly
Very Nice, Nice, Nice, Nice, Nice, Ugly, Ugly, Ugly, Very ugly, Very ugly
The median is between Ugly and Nice. Note that we cannot average this.

Example 2
The following grades were obtained by various students: 2, 4, 6, 6, 6, 8, 9, 9, 9. Note that there are 9 grades. The grade in the middle will be the (9 + 1)/2-th grade, so in this case the 5th grade. The grades are already in order and the 5th grade is 6. At least 50% of the students scored a 6 or higher, and alternatively at least 50% scored a 6 or lower.

Why (not) use the median?

The median takes into consideration the order of the values. It uses therefore more information about the values than the mode does. Since it requires order it cannot be determined for measurements on nominal level.

The disadvantage for the median is that it will ignore the 'size' of the numbers on an interval or ratio level. Note that for example 1, 1, 2, 3, 3 and the data 1, 1, 2, 8, 9 both have the same median.

In heavily skewed data the median is also sometimes preferred above the arithmetic mean, since it is not quickly influenced by extreme values (or outliers).

How to find the median?

The first step is always to order the items. Then for lists of values as used in the examples the two most common methods were used as well. The first is to simply cross out from both sides until you reach the middle. The second is to find the (n + 1)/2-th value.

For frequency tables and grouped tables an 'easy' way to find the median is by determining the cumulative frequencies. Then locate the value where the cumulative frequency is for the first time higher or equal to (n + 1)/2. Alternatively you can determine the relative cumulative frequencies and then find the group that hits the 50% or more as illustrated in Table 10.

Table 10
Example of median calculation for a frequency table


Opinion
Freq.
Rel. Freq.
Cumul. Rel. Freq.
Very boring
5
10%
10%
Boring
12
24%
34%
Good
20
40%
74%
Very good
13
26%
100%


Looking in the cumulative relative frequency column the first percentage above 50 is the 74%, which belongs to the opinion ‘Good’. The median opinion is therefore Good (50% or more of the people think it is Good or even Very Good).

You could also list all values of the frequency table separately and then find the value in the middle. Using Table 10 as an example, the first five people mention ‘Very Boring’ (VB) the next twelve Boring (B), etc. as illustrated in Figure 20 below for the first 33 people

Figure 20. Frequency table converted to raw data.
The median is then the (50+1)/2 = 25.5th person, so between person 25 and 26. Since both indicated ‘Good’ the median is indeed ‘Good’.

For grouped frequency tables it is also possible to use an interpolation to get an estimate of the median. This is discussed in the side note from this chapter.

History

The French term 'valeur médiane' can be found in Cournot's (1843) Exposition de la théorie des chances et des probabilités, while the earliest known reference in English is from Galton (1881) in Report of the Anthropometric.

>>Next section: (arithmetic) mean

References
Bowerman, B. L., O’Connell, R. T., Murphree, E. S., Huchendorf, S. C., Porter, D. C., & Schur, P. J. (2009). Business statistics in practice. Boston, MA.: McGraw-Hill/Irwin.
Cournot, A. A. (1843). Exposition de la théorie des chances et des probabilités. Paris: L. Hachette.
Galton, F. (1881). Report of the Anthropometric Committee. Report of the British Association for the Advancement of Science, 51, 225–272.
Johnson, R., & Kuby, P. (2011). Elementary Statistics. Cengage Learning.
McClave, J. T., Benson, P. G., & Sincich, T. (2005). Statistics for business and economics. Upper Saddle River, NJ: Pearson/Prentice Hall.

Steinberg, W. J. (2010). Statistics Alive! SAGE.
Weisstein, E. W. (n.d.). Median. Text. Retrieved May 10, 2014, from http://mathworld.wolfram.com/Median.html

woensdag 14 mei 2014

2.3.3. (arithmetic) Mean

What is it?

The mean is often defined by how it is calculated: the sum of all values divided by the number of items.

It is strange that for most measures of central tendency the definition often explains conceptually what it is, but for the mean the formula is often the definition. Some authors though use a conceptual definition for the mean as well (Watier, Lamontagne, & Chartier, 2011):
  • It is the amount or value that each group member would receive if the sum would be divided equally among all members.
  • It is the fulcrum (balancing point) for the distribution.

The fulcrum is the triangle in Figure 21.

Figure 21. Visualisation of the mean

A proof that the formula often seen for the arithmetic mean (sum up all items, divide by number of items) is indeed the fulcrum, can be found in Appendix D . An alternative method based on the fulcrum idea is known as using an ‘assumed mean’. In the side notes this is discussed in more details.

There are two symbols for the mean that are often used. The Greek letter mu (μ) is used to indicate a mean from a population, while a letter with a horizontal line (bar) is used for a mean from a sample (e.g. x̄ ).

Examples

List of values (raw data)
The mean from 2, 4, 8, 8, 10 is calculated by adding all the values and dividing it by the number of values. In this case: 2+4+8+8+10 = 32, and since there are 5 values the mean is 32/5 = 6.4.

Frequency table
If we convert the list of values in the previous example into a frequency table as shown in Table 11, it can be used to illustrate that the calculation for the mean in a frequency table is actually the same as for a list of values.

Table 11
Example frequency table for mean
Value
(x)
Frequency
(f)
2 1
4 1
8 2
10 1

To determine the mean we multiply each value by its frequency, sum these up and then divide by the number of values (the total frequency). In this case 1*2 + 1*4 + 2*8 + 1*10 = 32 and divide this by 1+1+2+1 = 5 to obtain again 32/5 = 6.4.

Grouped table 
The problem with a grouped table is that we do not have a single value (as was the case in the frequency table), but a range of values (classes), hence it is impossible to multiply the frequency by the class (i.e. how would you calculate 3 * (5<10)?). To overcome this problem we use the class midpoint to represent the entire class. We can then use these class midpoints as the value for that class and use the same technique as in the frequency table example to get an estimate for the mean. The grouped frequency table from the previous example might look like Table 12.

Table 12
Example for mean calculation from a grouped table

Class Midpoint
(x)
Frequency
(f)
0<6 3 2
5<9 7 2
9<11 10 1

The estimated mean now becomes (2*3 + 2*7 + 1*10) / (2 + 2 + 1) = (6 + 14 + 10) / 5 = 30 / 5 = 6. Note that this is different than the 6.4. By using the midpoints we assume the values in that class are distributed evenly (which might not be the case). The calculated mean from a grouped table is therefore always only an estimate of the mean.

Why (not) use the mean?

The mean can only be determined for numerical values, so should not be computed for measurements on nominal and ordinal level. Some argue though to also calculate the mean for ordinal data. An interesting article with references to both sides (those who favor using the mean for ordinal data also and those who don't) is from Knapp (1990).

The mean takes not only the order of the values into consideration, but also their 'weight'. It uses most information possible from the values and is therefore the preferred measure of central tendency for interval and ratio measurements (Stevens, 1946).

The mean is (because it takes the weight of the values into consideration) quickly influenced by extreme values (or outliers). In those cases the median might give a better idea of the center.

History

In Pythagoras time the Greek studied the arithmetic mean, but from a geometrical perspective. Aristotle (384-322 BC) (1850, p. 43) refers to the arithmetic mean. Hald (2003, p. 147) mentions that Tycho Brahe uses the arithmetic mean to average out his astronomical observations between 1582 and 1588. The original might be in ‘Meteorologiske dagbog’ (Brahe, 1876), probably somewhere after page 283 (sammendrag), but I don’t read Danish.

The use of a bar for the mean comes from applied mathematics where any average was represented by a bar (e.g. v̄ for velocity mean from Maxwell (1867, p. 64) and the centre of inertia from Kelvin & Trait (1879)). The first found use of μ for the mean (actually as a moment, not specifically the mean) can be found in the work from Pearson (1895, p. 347).

>>Next section: Using technology to determine measures of central tendency

References
Aristotle. (1850). The Nicomachean Ethics of Aristotle. (R. W. Browne, Trans.). London: Henry G. Bohn.
Brahe, T. (1876). Meteorologiske dagbog. Kjøbenhavn H.H. Thiele. Retrieved from http://archive.org/details/meteorologiskeda00brahuoft 

Hald, A. (2003). A history of probability and statistics and their applications before 1750. Hoboken, N.J.: Wiley.
Kelvin, W. T., & Tait, P. G. (1879). Treatise on Natural Philosophy. London: University Press. Retrieved from http://archive.org/details/treatiseonnatur01darwgoog
Knapp, T. R. (1990). Treating Ordinal Scales as Interval Scales: An Attempt To Resolve the Controversy. Nursing Research, 39(2), 121–123. doi:10.1097/00006199-199003000-00019
Maxwell, J. C. (1867). On the Dynamical Theory of Gases. Philosophical Transactions of the Royal Society of London, 157, 49–88. 
Pearson, K. (1895). Contributions to the Mathematical Theory of Evolution. II. Skew Variation in Homogeneous Material. Philosophical Transactions of the Royal Society of London. (A.), 186, 343–414. doi:10.1098/rsta.1895.0010
Stevens, S. S. (1946). On the Theory of Scales of Measurement. Science, 103(2684), 677–680. doi:10.1126/science.103.2684.677 
Watier, N. N., Lamontagne, C., & Chartier, S. (2011). What does the mean mean? Journal of Statistics Education, 19(2), 1–20.

dinsdag 13 mei 2014

2.3.4. Using technology to determine measures of central tendency


Excel
The median and mean can be determined in Excel by using the MEDIAN and AVERAGE function resp. There is also an AVERAGEIF and AVERAGEIFS function to calculate the mean for a specific group.
In earlier versions of Excel there was only one function 'MODE'. This would only return one value (the lowest in cases of multiple modes) without any warning of the existence of any multiple modes.
Since Excel 2010 the old MODE function still works, and is the same as MODE.SINGL, however there is also another function MODE.MULT. This function will show all modes, but is an array function so will require the use of CTRL+SHIFT+ENTER. A problem with this new function is that it requires you to estimate how many modes you expect and for each you go over will return an error. This can be overcome by combining different functions but is a bit tricky.
Another method to obtain the mode, median and mean is by using the Descriptive Statistics option in the Data Analysis tool.
A video showing an example of the above mentioned functions:


SPSS
A few different methods exist to obtain measures of central tendency in SPSS.
  • Analyze - Descriptive statistics – Frequencies, under ‘Statistics’ you can select the mode, median and mean.
  • Analyze - Descriptive statistics – Descriptives, under Options you can only select the mean.
  • Analyze - Descriptive statistics – Explore, no choices but will produce mean and median.
Note that if the data has multiple modes SPSS will only report the lowest, but will add a footnote that multiple modes exist.
A video showing an example of the above mentioned functions:
TI-83
The mean and median from a list can be easily determined by either using [STAT] – CALC – 1: 1-Var Stats, or [2nd][List] – MATH – 3: mean( (or 4: median).
There is unfortunately no function for the mode. The only thing that can be done is either to sort the list (use [STAT] – 2:SortA(, or create a bar-chart to visually check for peaks.
A video showing an example of the above mentioned functions:

vrijdag 9 mei 2014

2.4.1. Quantiles, Fractiles: Quartiles, Hinges, Quintiles, Octiles, Deciles and Percentiles

Quantiles (also known as fractiles) is a general term described as quantities that are corresponding to different fractions of the frequency (Kenney & Keeping, 1954), some of these have been given special names.
  • Quartiles: Dividing the data into four sections
  • Quintiles: Dividing the data into five sections
  • Octiles: Dividing the data into eight sections
  • Deciles: Dividing the data into ten sections
  • Percentiles: Dividing the data into 100 sections
The most common one used is probably the Quartiles. These are the values at 25% intervals, each with their own name:
  • Q0 = 0% =zero quartile = minimum
  • Q1 = 25% = first quartile, lower quartile or lower median
  • Q2 = 50% = second quartile = median
  • Q3 = 75% = third quartile, upper quartile or upper median
  • Q4 = 100% = fourth quartile = maximum
Determining which value is the first and third quartile turns out to be trickier than perhaps first thought. In total I managed to find 14 different ways to compute the quartiles, each with a slightly different result depending on the dataset. I’ll discuss three methods to illustrate a few different approaches. For those really interested in the details from the other methods I recommend to read the article Quartiles in Elementary Statistics from Langford (2006).

If you have a multiple of 4 ordinal or scale items, most methods agree. The first quartile will be then between the n/4th item and the n/4+1-th item, the third quartile will be between the n/4x3-th item and the n/4x3+1-th item. If we had for example 8 items, the first quartile would be between the 2nd and 3rd item, and the third quartile between the 6th and 7th. This nicely divides the data into four groups as illustrated in Figure 23.

Figure 23. General idea of quartiles

What if we have 9, 10 or 11 items? One approach is to re-arrange the items in a W or M shape. These are then known as hinges (as Tukey (1977) called them), or inclusive quartiles. Figure 24 below illustrates this approach.

Figure 24. Illustration of Tukey hinges

In the figure above you can see that if there are 8 items, the 2.5th item will be the lower quartile, and the 6.5th item the upper quartile, if there are 9 items the 3rd and 7th item, in case of 10 items the 3rd and 8th and in case of 11 items the 3.5th and 8.5th.

If you look closely you might notice that hinges are at the median of the upper and lower half of the data. In the case where n is odd, this does mean that the median itself is counted twice. This explains why it is also sometimes called the inclusive method. Some authors disagree with this and suggest to exclude the median when determining the quartiles as illustrated in Figure 25.

 
Figure 25. Exclusive method illustration for quartiles

In the exclusive method, the median itself is removed from the data set and then the median from the lower part and upper part form the first and third quartile. If there are 8 items, the lower quartile will be the 2.5th item and the upper quartile the 6.5th. In case of 9 items it will be the 2.5th and 7.5th item, with 10 items the 2.5th and 8.5th and with 11 items the 3rd and 9th.

Another approach is focusses on the 25% idea from a quartile. If we have n items, then 25% of this will be at n x 0.25. If this is an integer (i.e. n is divisible by four) then the first quartile will be the average of n x 0.25-th item and the next one (n x 0.25 + 1-th). If it’s not an integer we simply round up. This approach is known as the cumulative or empirical distribution function and is the method eventually proposed by Langford (2006). The method is illustrated in Figure 26.

Figure 26. Illustration of the cumulative distribution function for quartiles

If there are 8 items then for the lower quartile we obtain 8 x 0.25 = 2, which is an integer so it will be between the 2nd and 3rd item. For the upper quartile we obtain 8 x 0.75 = 6, which is an integer so it will be between the 6th and 7th item. If there are 9 items we get 9 x 0.25 = 2.25, which gets rounded up to 3, so the lower quartile will be the 3rd item. For the upper quartile we get 9 x 0.75 = 6.75 =round up> 7. If there are 10 items the calculations go resp. 10 x 0.25 = 2.5 =round up> 3rd item, and 10 x 0.75 = 7.5 =round up> 8th item. If there are 11 items we get 11 x 0.25 = 2.75 =round up> 3rd item, and 11 x 0.75 = 8.25 =round up> 9th item.

The empirical distribution method can easily be adopted to determine the quintiles (simply use 0.2, 0.4, 0.6 and 0.8 instead of 0.25 and 0.75), deciles (use multiples of 0.1), octiles (use multiples of 0.125 and percentiles (use any value between 0 and 1).

Note that averaging out two values is only possible if numbers are used. If an ordinal data set is used this might not always be possible. One could then simply write something like “the lower quartile of the t-shirts sizes falls between small and medium”.

History
The first known use of the terms upper quartile and lower quartile comes from McAlister (1879). The term Hinges was introduced by Tukey (1977). The general term Quantiles is found was used by Kendall (1940). Galton (1885) uses the term percentile to describe the median as the 50th percentile and had used the term decile (1881) as well. Fisher, Thornton, & Mackenzie (1922) introduce the term quintiles.

>>Next section: Outliers, unusual scores and z-scores
 
References
Fisher, R. A., Thornton, H. G., & Mackenzie, W. A. (1922). The Accuracy of the Plating Method of Estimating the Density of Bacterial Populations. Annals of Applied Biology, 9, 325–359.
Galton, F. (1881). Report of the Anthropometric Committee. Report of the British Association for the Advancement of Science, 51, 225–272.
Galton, F. (1885). Some results of the Anthropometric Laboratory. Journal of the Anthropological Institute, 14, 275–287.
Kendall, M. G. (1940). Note on the Distribution of Quantiles for Large Samples. Supplement to the Journal of the Royal Statistical Society, 7(1), 83–85.
Kenney, J. F., & Keeping, E. S. (1954). Mathematics of Statistics; Part one (3rd ed.). New York: D. Van Nostrand Company.
Langford, E. (2006). Quartiles in Elementary Statistics. Journal of Statistics Education, 14(3). Retrieved from http://www.amstat.org/publications/jse/v14n3/langford.html
McAlister, D. (1879). The Law of the Geometric Mean. Proceedings of the Royal Society of London, 29(196-199), 367–376. doi:10.1098/rspl.1879.0061
Tukey, J. W. (1977). Exploratory Data Analysis. Pearson.

donderdag 8 mei 2014

2.4.2. Outliers, Unusual Scores and Z-scores

If you have entered the responses from 50 people on 10 questions, you have entered 50 x 10 = 500 observations. It isn’t unlikely that you might have made a small mistake. If this is just a small issue (e.g. you entered a 23 as the age instead of 25 for one person) it will not have a huge impact, but if you entered a zero too many it might (e.g. you entered 230 as the age instead of 23). By checking for outliers or unusual scores you might detect such an error.

Sometimes an outlier is very interesting. How comes this person is so old but still plays more video games than a teenager? Although often outliers are sometimes simply removed from the data, this should only be done with great care. Outliers are as the name implies not very common, but are part of the data and population.

A simple method of detecting outliers is by generating a graph of your data and simply look for any unusual observations. This method might not be very scientific, but is highly recommended. There are of course also other methods developed.

The APA Dictionary of Statistics and Research methods simply defines an outlier as “an extreme observation or measurement, that is, a score that significantly differs from all others obtained” (Zedeck, 2014, p. 248). This does leave the option open as to define when something is ‘significantly different’.

One method sometimes used is to define an outlier as any data point that is more than a fixed number of standard deviations away from the mean. What this fixed number should be varies per source. Aggarwal (2013) mentions 3, Miller (1991) suggest 2.5 or even 2 and Cousineau & Chartier (2010) suggest to let it depend on the sample size. The number of standard deviations a value is above or below the mean, is known as the z-score of that number. This z-score can easily be obtained by subtracting the mean from the number (so you have the difference with the mean), and then divide by the standard deviation (to obtain how many times this difference will fit into the standard deviation).

A problem with this method is that the mean and standard deviation themselves are effected by outliers. Another approach is therefore to use the median instead of the mean, and either the median absolute deviation instead of the standard deviation (Iglewicz & Hoaglin, 1993; Leys, Ley, Klein, Bernard, & Licata, 2013), or the Inter Quartile Range (Carling, 2000).

A third method is to consider every item that is 1.5 times the Interquartile Range above the third quartile, or below the first to be a potential outlier, and each value that is even three times the IQR above the 3rd quartile or below the 1st quartile an extreme potential outlier (Tukey, 1977).

Besides the three methods described above there are also more advanced techniques, such as Grubb’s test (Grubbs, 1950), Dixon’s Q test (Dixon, 1950) and the Extreme Studentized Deviation test (Rosner, 1983). Entire books have been written about detecting outliers (Aggarwal, 2013; Barnett & Lewis, 1994; Rousseeuw & Leroy, 2003).

Two things though to be clear:
  1. If you have one or more outliers, it does not automatically mean these answers were wrong
  2. If you do not have any outliers it does not automatically mean you haven’t made any mistakes in your data entry.
History
Pearson (1903) mentions the term outlier, but the study of unusual scores is a lot older. In Chauvenet (1863) discusses “criterion for the rejection of doubtful observations” (p. 558).

References
Aggarwal, C. C. (2013). Outlier analysis. New York: Springer.
Barnett, V., & Lewis, T. (1994). Outliers in Statistical Data (3rd ed.). Chichester ; New York: Wiley.
Carling, K. (2000). Resistant outlier rules and the non-Gaussian case. Computational Statistics & Data Analysis, 33(3), 249–258. doi:10.1016/S0167-9473(99)00057-2
Chauvenet, W. (1863). Appendix. Method of Least Squares. In A Manual of Spherical and Practical Astronomy: Theory and use of astronomical instruments, method of least squares (1st ed., Vol. 2, pp. 469–566). Philadelphia: J. B. Lippincott & Company.
Cousineau, D., & Chartier, S. (2010). Outliers detection and treatment: a review. International Journal of Psychological Research, 3(1), 58–67.
Dixon, W. J. (1950). Analysis of Extreme Values. The Annals of Mathematical Statistics, 21(4), 488–506. doi:10.1214/aoms/1177729747
Grubbs, F. E. (1950). Sample Criteria for Testing Outlying Observations. The Annals of Mathematical Statistics, 21(1), 27–58. doi:10.1214/aoms/1177729885
Iglewicz, B., & Hoaglin, D. C. (1993). How to detect and handle outliers. Milwaukee, Wis: ASQC Quality Press.
Leys, C., Ley, C., Klein, O., Bernard, P., & Licata, L. (2013). Detecting outliers: Do not use standard deviation around the mean, use absolute deviation around the median. Journal of Experimental Social Psychology, 49(4), 764–766. doi:10.1016/j.jesp.2013.03.013
Miller, J. (1991). Short report: Reaction time analysis with outlier exclusion: Bias varies with sample size. The Quarterly Journal of Experimental Psychology Section A, 43(4), 907–912. doi:10.1080/14640749108400962
Pearson, K. (1903). On the Laws of Inheritance in Man: I. Inheritance of Physical Characters. Biometrika, 2(4), 357–462. doi:10.2307/2331507
Rosner, B. (1983). Percentage Points for a Generalized ESD Many-Outlier Procedure. Technometrics, 25(2), 165. doi:10.2307/1268549
Rousseeuw, P. J., & Leroy, A. M. (2003). Robust Regression and Outlier Detection (1st ed.). Hoboken, NJ: Wiley-Interscience.
Tukey, J. W. (1977). Exploratory Data Analysis. Pearson.
Zedeck, S. (Ed.). (2014). APA dictionary of statistics and research methods (First edition.). Washington, DC: American Psychological Association.

2.5. Measures of dispersion (variability/spread)

Descriptive statistics tries to describe data. It does this by tables and diagrams, or by representing the data by some form of measurement. The most commonly form of measurement to describe data, are the measurements of central tendency. However, measures of central tendency do not give a very clear picture of the data and are therefore (or should be) accompanied by a measure of dispersion.

To put it bluntly: if your head is in a burning oven and your feet are in a refrigerator, on average you will be doing just fine. Another statistical joke that makes the point is that three hunters go deer hunting. One shoots two meter to the left of the deer, the other shoots two meter to the right. The third shouts: yippie on average we got him! Measures of dispersion provide information about how varied the numbers were. Did the people agree with each other? Were there many differences? etc.

For nominal variables dispersion is often not calculated. One measurement is the Variation Ratio (VR) (normally credited to Freeman (1965)), which is the percentage of cases that do not fall in the modal category. It is one of many types of Qualitative Variation. On Wikipedia a long list of other Qualitative Variation coefficients can be found.

References
Freeman, L. C. (1965). Elementary applied statistics: for students in behavioral science. New York: Wiley.