Unit 1, lesson 2

Types of Data and Measurement

How to tell categorical from numerical and discrete from continuous variables, what the four levels of measurement allow, and how operational definitions, accuracy, precision, rounding and 0/1 indicators shape conclusions.

  • Video 2
  • Questions, Variables and Data Quality

The number 6 in a spreadsheet could name a visit, count six books or record a wait of six minutes. Which calculations make sense depends on which of these it is, so a data table is only as useful as the description of its columns. This lesson classifies variables by the kind of values they take and the comparisons those values support. It also shows how the way a value is defined, measured, rounded or coded changes what can be concluded from it.

Key terms

Variable

Definition In a data table each row, also called a record or an observation, describes one observational unit, and each column is a variable, a characteristic recorded for every unit that can differ from unit to unit. A value is a single entry, the value of one variable for one unit. A variable whose only role is to name the units, such as a visit number, is an identifier.

In plain words A row is one unit, a column is one characteristic, and a cell holds what was recorded for that unit and that characteristic. The entries of a row all belong to the same unit, so a row is sorted or moved as a whole.

Example The first six visits of a constructed library example give the table below. Each row is one completed visit to a collection desk, and the waits are exact constructed values.

Visit IDReservedSatisfactionBooksWait (min)
V01OnlineSatisfied12
V02At branchNeutral23
V03OnlineSatisfied14
V04OnlineVery satisfied35
V05At branchDissatisfied27
V06OnlineSatisfied49

Row V02 records a 3-minute wait, two books, a reservation made at the branch and a neutral answer to the satisfaction question, all about the same visit. The table has six rows because it records six visits. A person who visits twice appears in two rows, so the number of rows need not equal the number of people.

Categorical and numerical variables

Definition A categorical variable, also called qualitative, places each unit in one of a set of categories, which may or may not have a natural order. A numerical variable, also called quantitative, records a number that counts or measures an amount in stated units, so that differences between its values, and their averages, are amounts of the same thing. Writing values with digits does not make a variable numerical. Identifiers and numeric codes for categories are still categorical, although the 0/1 coding of a condition has a useful numerical reading, described below under binary indicator.

In plain words Ask whether arithmetic on the values answers a question about the units. For categories the natural summaries are the count and the proportion of units in each category. For numerical values, differences and averages can also make sense.

Example In the library table, the reservation method and satisfaction are categorical, while the number of books and the wait are numerical. The visit ID stays categorical even if the visits are renumbered 101 to 106. The mean of those labels is 103.5, but renumbering the same visits 201 to 206 changes it to 203.5 without changing anything about the visits, so this mean measures nothing about them.

Discrete and continuous variables

Definition A numerical variable is discrete if its possible values form a finite or countably infinite list, such as the counts 0,1,2,…0, 1, 2, \dots. Discrete values need not be whole numbers, since a quantity whose possible values come in steps of one half, such as shoe sizes in a system with half sizes, is discrete as well. A numerical variable is continuous if, in the model being used, it can take any value in an interval of real numbers, as lengths, masses and durations can. A recorded value of a continuous quantity is always written to some recording resolution, the smallest step in which values are recorded, so the classification refers to the quantity and not to the digits that appear in the table.

In plain words Discrete values can be listed one by one, while continuous values fill a whole range. The average of a discrete variable can fall between its possible values, and then it describes the group, not any single unit.

Example The number of books collected is discrete. The six counts add to 13, and the mean

xˉ=13 books6 visits≈2.17 books per visit\begin{aligned} \bar{x} &= \frac{13\ \text{books}}{6\ \text{visits}} \\[0.4em] &\approx 2.17\ \text{books per visit} \end{aligned}

is a sensible summary even though no visit collected a fraction of a book. The wait is continuous, since between 5 and 6 minutes a wait can last 5.2 minutes, 5.21 minutes or any other length. The six example waits happen to be whole numbers. If a different recording rule rounds every wait to the nearest minute, waits of 6.4 and 5.6 minutes are both recorded as 6, although the first is more than 6 minutes and the second is not. The rounded record alone cannot tell which of the two waits was longer than 6 minutes.

Levels of measurement

Definition The levels of measurement classify variables by the comparisons their values support.

  • Nominal. Categories with no natural order, so two values can only be compared as the same or different.
  • Ordinal. Categories with a natural order, so values can also be ranked, but the order alone does not fix the size of the steps between categories.
  • Interval. Numbers on a scale with equal units, so differences are meaningful, but zero is a chosen reference point rather than an absence of the quantity, so ratios of values are not meaningful.
  • Ratio. An interval scale whose zero means none of the quantity, so ratios are meaningful as well.

Each level supports every comparison of the levels listed before it. Averaging numeric codes of ordinal categories treats the gaps between the codes as the distances between the categories, which is an assumption the order itself does not supply.

In plain words The level tells you which statements about the values mean something. “Twice as long” makes sense for durations. “Ten degrees warmer” makes sense for Celsius temperatures, but “twice as warm” does not.

Example Duration is on a ratio scale. A 9-minute wait is three times as long as a 3-minute wait, and in seconds the same waits are 540 and 180, again a ratio of 3. Temperature in degrees Celsius is on an interval scale. Using F=1.8C+32F = 1.8C + 32, readings of 10∘C10^\circ\text{C} and 20∘C20^\circ\text{C} become 50∘F50^\circ\text{F} and 68∘F68^\circ\text{F}, and the ratios of the readings are

2010=2,6850=1.36.\begin{gathered} \frac{20}{10} = 2, \\[0.4em] \frac{68}{50} = 1.36. \end{gathered}

The ratio changes with the unit, so the claim that 20∘C20^\circ\text{C} is twice as warm as 10∘C10^\circ\text{C} has no unit-free meaning. Differences carry over consistently, since a difference of 10 Celsius degrees is always a difference of 1.8×10=181.8 \times 10 = 18 Fahrenheit degrees. Temperature in kelvins has its zero at absolute zero, the lowest possible temperature, so it is on a ratio scale. In the library table, satisfaction is ordinal and the reservation method is nominal.

Operational definition, accuracy and precision

Definition An operational definition of a variable is a rule that says exactly how its value is obtained for each unit. It states what is measured and, where they apply, when the measurement starts and stops, the instrument or question used, the units, the recording resolution and how a missing value is marked. Measurement accuracy is how close a measured value is to the true value of the quantity that the definition specifies. Measurement precision is how closely repeated measurements of the same quantity agree with each other under stated conditions. The resolution of an instrument or a record, the smallest change it can show, is a separate property, and a fine resolution guarantees neither accuracy nor precision.

In plain words Two people timing “the wait” with different start and stop rules are measuring different things, and agreeing on units does not fix that. Precision is about repeated readings agreeing with each other, and accuracy is about readings being close to the truth. A set of readings can agree closely and still all miss in the same direction.

Example In the library table, the wait runs from joining the collection queue until a staff member begins helping. Stopping the clock when the books are handed over would measure a different, longer interval. Now suppose a timer that shows two decimal places of a minute always starts 30 seconds late. Timing a test interval known to last exactly 4 minutes on three occasions, it reads 3.50, 3.51 and 3.49 minutes. The readings agree to within 0.02 minutes, so they are precise, but each is about 0.5 minutes short, so they are not accurate. The fine display cannot recover the half minute missed at the start.

Binary indicator

Definition For a condition that each unit either meets or does not meet, the binary indicator, also called a 0/1 indicator, equals 1 for a unit that meets the condition and 0 for a unit that does not. If I1,…,InI_1, \dots, I_n are the indicators of nn units and kk of the units meet the condition, then

I1+I2+⋯+Inn=kn,\frac{I_1 + I_2 + \cdots + I_n}{n} = \frac{k}{n},

so the sum of the indicators is the count of units that meet the condition and their mean is the proportion of such units. Any variable with two categories can be coded this way once one category is chosen to receive the 1.

In plain words Coding yes as 1 and no as 0 gives categories a numeric code whose average has a direct meaning, the share of yes answers. Swapping which category gets the 1 turns that mean into one minus the share. This works because the coding was chosen to answer one counting question, and it does not make arbitrary category codes meaningful to average.

Example For the waits 2, 3, 4, 5, 7 and 9 minutes, the indicator of a wait strictly longer than 6 minutes takes the values 0, 0, 0, 0, 1 and 1. The indicators add to 2, the number of such waits, and their mean is 2/6=1/32/6 = 1/3, the sample proportion p^\hat{p} of waits over 6 minutes. A wait of exactly 6 minutes would get a 0. Coding the indicator needs enough detail to decide the condition, so for a wait recorded only as a rounded 6 it may not be possible.

Check yourself

  1. A school records completed trips to school during one week. Each row holds a pupil ID number, the transport method, the trip duration rounded to the nearest minute, the number of vehicle changes and a difficulty rating of easy, moderate or difficult. What is the observational unit, and how would you classify each variable?
Show the answer

The unit is one trip. A pupil can make several trips, so the same pupil ID can appear in several rows, and the number of rows need not equal the number of pupils. The pupil ID is nominal even though it is written with digits. It names the pupil who made the trip, not the trip itself, and its mean would describe no characteristic of the pupils. The transport method is nominal and the difficulty rating is ordinal, both categorical. The number of vehicle changes is numerical and discrete, on a ratio scale, since zero means no change at all. The duration is numerical, a continuous quantity recorded at a resolution of one minute, and also on a ratio scale.

  1. The same school records five trips, rounded to the nearest minute, as 4, 7, 6, 9 and 3 minutes. Code a 0/1 indicator for a trip that lasted more than 6 minutes and find the proportion of such trips. Which record causes trouble?
Show the answer

A trip recorded as 7 or 9 minutes lasted at least 6.5 minutes, so its indicator is 1. A trip recorded as 4 or 3 minutes lasted at most 4.5 minutes, so its indicator is 0. The trip recorded as 6 minutes lasted somewhere from about 5.5 to about 6.5 minutes, so it may or may not have lasted more than 6 minutes. With that indicator set to 0 the proportion is 2/5=0.42/5 = 0.4, and with it set to 1 the proportion is 3/5=0.63/5 = 0.6. The rounded records cannot decide between the two, so this question needs a finer recording resolution.

  1. A satisfaction question has the ordered answers very dissatisfied, dissatisfied, neutral, satisfied and very satisfied. Group 1 answers neutral twice. Group 2 answers dissatisfied once and very satisfied once. Compare the group means under the codes 1, 2, 3, 4, 5 and under the codes 1, 2, 5, 6, 7, given in the order of the answers. What does the comparison show?
Show the answer

With the codes 1 to 5, group 1 has mean 3 and group 2 has mean (2+5)/2=3.5(2 + 5)/2 = 3.5, so group 2 looks more satisfied. With the codes 1, 2, 5, 6, 7, group 1 has mean 5 and group 2 has mean (2+7)/2=4.5(2 + 7)/2 = 4.5, so group 1 looks more satisfied. Both codings keep the answers in order, yet the comparison reverses, because the order alone does not fix the distances between categories. A mean of ordinal codes therefore rests on an extra assumption about spacing. Summaries that use only the order, such as the share of answers at satisfied or above, do not depend on the coding. That share is 0 for group 1 and 1/2 for group 2.

How this lesson connects