14 1. Summarizing Data 1 4 9 16 25 36 49 64 81 100 1 4 9 16 25 36 49 64 81 100 Figure 1.8. Illustrations of two methods for determining quantiles from data. Arrows indicate the locations of the 0.25-, 0.5-, and 0.75-quantiles. intro-quantile quantile((1:10)^2) 0% 25% 50% 75% 100% 1.00 10.75 30.50 60.25 100.00 A second scheme is just like the first one except that the data values are placed midway between the unit marks. In particular, this means that the 0-quantile is not the smallest value. This could be useful, for example, if we imagined we were trying to estimate the lowest value in a population from which we only had a sample. Probably the lowest value overall is less than the lowest value in our particular sample. The only remaining question is how to extrapolate in the last half unit on either side of the ruler. If we set quantiles in that range to be the minimum or maximum, the result is another type of quantile(). Example 1.2.2. The method just described is what type=5 does. intro-quantile05a quantile((1:10)^2,type=5) 0% 25% 50% 75% 100% 1.0 9.0 30.5 64.0 100.0 Notice that quantiles below the 0.05-quantile are all equal to the minimum value. intro-quantile05b quantile((1:10)^2,type=5,seq(0,0.10,by=0.005)) 0% 0.5% 1% 1.5% 2% 2.5% 3% 3.5% 4% 4.5% 5% 5.5% 6% 6.5% 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.00 1.15 1.30 1.45 7% 7.5% 8% 8.5% 9% 9.5% 10% 1.60 1.75 1.90 2.05 2.20 2.35 2.50 A similar thing happens with the maximum value for the larger quantiles. Other methods refine this idea in other ways, usually based on some assump- tions about what the population of interest is like. Fortunately, for large data sets, the differences between the different quantile methods are usually unimportant, so we will just let R compute quantiles for us using the quantile() function. For example, here are the deciles and quartiles of the Old Faithful eruption times. faithful-quantile quantile(faithful$eruptions,(0:10)/10) 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 1.6000 1.8517 2.0034 2.3051 3.6000 4.0000 4.1670 4.3667 4.5330 4.7000 100% 5.1000 quantile(faithful$eruptions,(0:4)/4)
Previous Page Next Page