Skip to main content

Section A.3 Chapter 3: Descriptive Statistics

Subsection A.3.1 Exercise 3.1

  1. Consider the data “x1". From the summary we see that it is distributed in the range between 0 and slightly below 5. The central 50% of the distribution are located between 2.5 and 3.8. The mean and median are approximately equal to each other, which suggests an approximately symmetric distribution. Consider the histograms in Figure 3.5.2. Histograms 1 and 3 correspond to a distributions in the appropriate range. However, the distribution in Histogram 3 is concentrated in lower values than suggested by the given first and third quartiles. Consequently, we match the summary of “x1" with Histogram 1.
    Consider the data “x2". Again, the distribution is in the range between 0 and slightly below 5. The central 50% of the distribution are located between 0.6 and 1.8. The mean is larger than the median, which suggests a distribution skewed to the right. Therefore, we match the summary of “x2" with Histogram 3.
    For the data in “x3" we may note that the distribution is in the range between 2 and 6. The histogram that fits this description is Histograms 2.
    The box plot is essentially a graphical representation of the information presented by the function “summary". Following the rational of matching the summary with the histograms we may obtain that Histogram 1 should be matched with Box-plot 2 in Figure 3.5.3, Histogram 2 matches Box-plot 3, and Histogram 3 matches Box-plot 1. Indeed, it is easier to match the box plots with the summaries. However, it is a good idea to practice the direct matching of histograms with box plots.
  2. The data in “x1" fits Box-plot 2 in Figure 3.5.3. The value 0.000 is the smallest value in the data and it corresponds to the smallest point in the box plot. Since this point is below the bottom whisker it follows that it is an outlier. More directly, we may note that the inter-quartile range is equal to \(IQR = 3.840 - 2.498 = 1.342\text{.}\) The lower threshold is equal to \(2.498 - 1.5 \times 1.342 = 0.485\text{,}\) which is larger that the given value. Consequently, the given value 0.000 is an outlier.
  3. Observe that the data in “x3" fits Box-plot 3 in Figure 3.5.3. The vale 6.414 is the largest value in the data and it corresponds to the endpoint of the upper whisker in the box plot and is not an outlier. Alternatively, we may note that the inter-quartile range is equal to \(IQR = 4.690 - 3.391 = 1.299\text{.}\) The upper threshold is equal to \(4.690 + 1.5 \times 1.299 = 6.6385\text{,}\) which is larger that the given value. Consequently, the given value 6.414 is not an outlier.

Subsection A.3.2 Exercise 3.2

  1. In order to compute the mean of the data we may write the following simple R code:
    x.val <- c(2,4,6,8,10)
    freq <- c(10,6,10,2,2)
    rel.freq <- freq/sum(freq)
    x.bar <- sum(x.val*rel.freq)
    x.bar
    
    ## [1] 4.666667
    
    We created an object “x.val" that contains the unique values of the data and an object “freq" that contains the frequencies of the values. The object “rel.freq" contains the relative frequencies, the ratios between the frequencies and the number of observations. The average is computed as the sum of the products of the values with their relative frequencies. It is stored in the objects “x.bar" and obtains the value 4.666667.
    An alternative approach is to reconstruct the original data from the frequency table. A simple trick that will do the job is to use the function “rep". The first argument to this function is a sequence of values. If the second argument is a sequence of the same length that contains integers then the output will be composed of a sequence that contains the values of the first sequence, each repeated a number of times indicated by the second argument. Specifically, if we enter to this function the unique value “x.val" and the frequency of the values “freq" then the output will be the sequence of values of the original sequence “x":
    x <- rep(x.val,freq)
    x
    mean(x)
    
    ##  [1]  2  2  2  2  2  2  2  2  2  2  4  4  4  4  4  4  6  6  6  6  6  6  6
    ## [24]  6  6  6  8  8 10 10
    
    ## [1] 4.666667
    
    Observe that when we apply the function “mean" to “x" we get again the value 4.666667.
  2. In order to compute the sample standard deviation we may compute first the sample variance and then take the square root of the result:
    var.x <- sum((x.val-x.bar)^2*freq)/(sum(freq)-1)
    sqrt(var.x)
    
    ## [1] 2.425914
    
    Notice that the expression “sum((x.val-x.bar)^2*freq)" compute the sum of square deviations. The expression “(sum(freq)-1)" produces the number of observations minus 1 (\(n-1\)). The ratio of the two gives the sample variance.
    Alternatively, had we produced the object “x" that contains the data, we may apply the function “sd" to get the sample standard deviation:
    sd(x)
    
    ## [1] 2.425914
    
    Observe that in both forms of computation we obtain the same result: 2.425914.
  3. In order to compute the median one may produce the table of cumulative relative frequencies of “x":
    data.frame(x.val,cumsum(rel.freq))
    
    Recall that the object “x.val" contains the unique values of the data. The expression “cumsum(rel.freq)" produces the cumulative relative frequencies. The function “data.frame" puts these two variables into a single data frame and provides a clearer representation of the results.
    Notice that more that 50% of the observations have value 4 or less. However, strictly less than 50% of the observations have value 2 or less. Consequently, the median is 4. (If the value of the cumulative relative frequency at 4 would have been exactly 50% then the median would have been the average between 4 and the value larger than 4.)
    In the case that we produce the values of the data “x" then we may apply the function “summary" to it and obtain the median this way
    summary(x)
    
    ##   x.val cumsum.rel.freq.
    ## 1     2        0.3333333
    ## 2     4        0.5333333
    ## 3     6        0.8666667
    ## 4     8        0.9333333
    ## 5    10        1.0000000
    
  4. As for the inter-quartile range (IQR) notice that the first quartile is 2 and the third quartile is 6. Hence, the inter-quartile range is equal to 6 - 2 = 4. The quartiles can be read directly from the output of the function “summary" or can be obtained from the data frame of the cumulative relative frequencies. For the later observe that more than 25% of the data are less or equal to 2 and more 75% of the data are less or equal to 6 (with strictly less than 75% less or equal to 4).
  5. In order to answer the last question we conduct the computation: \((10 - 4.666667)/2.425914 = 2.198484\text{.}\) We conclude that the value 10 is approximately 2.1985 standard deviations above the mean.