Tutorial 2

Learning objectives

After this tutorial the student should be able to:

  • name the correct measure for variability given the variable;

  • determine and interpret the value for the range, interquartile range, percentiles, variance, and standard deviation;

  • interpret a box plot, side-by-side box plots, and a scatter plot;

  • choose the correct graph to use (box plot, side-by-side box plots, or scatter plot) given the data.

Descriptive analysis for one variable: measures of variability

Read:

    • paragraph 3.5 pp.90-98 (up to Example 3.10, skip on p.91 ‘grouped data’ and pp.92 ‘The computation of percentiles:\(\ldots\)’-95 ‘Example 3.8’), or
    • paragraph 3.5 pp.85-93 (up to Example 3.10, skip on p.87 ‘grouped data’ and pp.87 ‘The computation of percentiles:\(\ldots\)’-90 ‘Example 3.8’).

The following measures of variability for a sample are discussed: the range, percentiles, the interquartile range, the variance and the standard deviation.

The range of a set of measurements is the difference between the largest and the smallest measurement of the data set.

The p-th percentile of a set of \(n\) measurements arranged in increasing order is that value that has at most \(p\)% of the measurements below it and at most \((100 - p)\)% above it.

The 25th percentile is called the first (lower) quartile (denoted by \(Q_1\)), the 50th percentile is the median (second or middle quartile, and sometimes denoted by \(Q_2\)) and the 75th percentile is called the third (upper) quartile (denoted by \(Q_3\)).

The interquartile range (denoted by IQR) of a set of measurements is the difference between the third (upper) quartile and the first (lower) quartile. \[ \mbox{IQR}= Q_3 - Q_1\]

The variance \(s^2\) of a set of \(n\) measurements \(y_1, y_2, \ldots , y_n\) with mean \(\mu\) is the sum of the squared deviations of the observations from the sample mean, divided by \(n-1\). \[s^2 = \frac{\sum(y_i - \bar{y})^2}{n-1} \]

The standard deviation \(s\) of a set of \(n\) measurements \(y_1, y_2, \ldots , y_n\) is the square root of the variance \(s^2\).

\[ s = \sqrt{s^2} \]

ImportantRemark about variance and standard deviation.

Some books use for the definition of \(s^2\) and \(s\) in the denominator \(n\) instead of \(n - 1\). (Graphing) Calculators usually have both versions, e.g., designated \(\sigma_n\) and \(\sigma_{n - 1}\) for \(s\).

Example 2.1 (continuation from Example 1.3)

The range equals: \(12 - 1 = 11\).

The first (lower) quartile is the 14th observation, therefore equal to \(4\); the third (upper) quartile is the 42th observation, therefore equals \(7\). The interquartile range is then \(\mbox{IQR} = 7 - 4 = 3\).

The variance is \(s^2 \approx 6.9953\) and the standard deviation is \(s \approx \sqrt{6.9953} \approx 2.645\). Use your (graphing) calculator to check this.

Asking for a numerical summary in R or R Commander, provides not only the mean and the median (as shown in Example 1.3) but also the quartiles. The ‘numerical summary’ function in R Commander numSummary() additionally provides the standard deviation,the IQR, and the number of observations \(n\). These can be also be obtained using the following commands in R:

sd(x = farmers_count$plots)
#> [1] 2.64486
IQR(x = farmers_count$plots)
#> [1] 3
quantile(x = farmers_count$plots)
#>   0%  25%  50%  75% 100% 
#>    1    4    5    7   12
length(x = farmers_count$plots)
#> [1] 55

Descriptive analysis for one variable: box plot

Read about the box plot:

    • paragraph 3.6 pp.104-109, or
    • paragraph 3.6 pp.97-102.

The box plot (also called box-and-whiskers plot) is a summary plot of a quantitative variable based on the median, quartiles, and extreme values.

The box represents the interquartile range, which contains 50% of the values. The whiskers are lines that extend from the box to the highest and lowest values, when there are no outliers (extreme values) in the data set. A bold line inside the box represents the median.

Example 2.2 (continuation from Example 1.2)

A researcher did a small study about the cultivation under glass. He asked 33 growers the area of cultivation under glass. The results are shown in Table 2.

The corresponding box plot, constructed in R and displayed in Figure 1, shows that the sample distribution is skewed to the right and that 2 outlying observations (values 98 and 100) are present.

Figure 1: Box plot for area of cultivation under glass.
ImportantRemark about box plots.

Box plots should not be created for small sample sizes.

Descriptive analysis for two quantitative variables: scatter plot

Read about the scatter plot:

    • paragraph 3.7 pp.111 (last two lines above Table 3.15)-113 (first 13 lines), or
    • paragraph 3.7 pp.104 (last two lines)-106 (first 18 lines).

Descriptive analysis for one qualitative and one quantitative variable: side-by-side box plots

Read about the side-by-side box plots:

    • paragraph 3.7 pp.115 (last three lines)-119 (skip Figure 3.31 p.116), or
    • paragraph 3.7 pp.108 (last ten lines)-112 (skip Figure 3.31 p.109).

Exercises to be done during the tutorial

Exercise 2.1 up to and including Exercise 2.4 are in the presentation handouts of Tutorial 2. For answers/feedback check Brightspace.

Post-class activity

Watch:

The clip is linked on Brightspace.

Exercises to be done after the tutorial

For answers/feedback check Brightspace.

Exercise 2.5

A researcher registers the number of plots (variable \(y\)) from 55 farmers having companies of nearly the same size. The results are shown in Table 3.

The R Commander numerical summary output for the number of plots for 55 farmers is given in Table 1.

Table 1: Numerical summary for the number of plots for 55 farmers.
mean sd IQR 0% 25% 50% 75% 100% n
5.490909 2.64486 3 1 4 5 7 12 55

The default R summary output for the number of plots for 55 farmers is:

#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>   1.000   4.000   5.000   5.491   7.000  12.000

a. Use the R Commander numerical summary output in Table 1 to determine the range and the IQR. Check your answer with respect to the IQR with the default R summary output provided above.

b. Find the median in the default R summary output provided above and check your answer with the R Commander numerical summary output in Table 1.

c. Check, using the R Commander numerical summary output in Table 1 and a (graphing) calculator, that the variance \(s^2 \approx 6.995\).

Exercise 2.6

Use the data from either

to calculate the range, interquartile range, variance, and standard deviation.

Exercise 2.7

Do either

Replace the two data points as mentioned in the exercise. What will be the result from these changes with respect to the range, interquartile range, variance, and standard deviation? Do not recalculate the requested measures, but provide an argumentation.

Exercise 2.8

Do either

This exercise is slightly modified compared to the version presented in O&L, use the ordered data as provided in Table 2.

The treatment times (in minutes) for patients at a health clinic are as follows:

Table 2: Treatment times at a health clinic for 50 patients.
7 11 13 15 17 20 21 24 28 32
8 12 13 16 17 20 22 24 29 33
10 12 14 16 18 21 22 24 29 35
10 12 15 16 18 21 24 26 29 45
11 12 15 16 19 21 24 27 31 54

Exercise 2.9

Do either

Exercise 2.10

Do either