Tutorials › Introduction to Statistics › Categorical and Quantitative Variables

Variables, Data Types and Questions · Tutorial 3 of 996

Categorical and Quantitative Variables

Classify variables by whether their values identify groups or represent amounts on which arithmetic is meaningful.

Beginner 9 min read

What You'll Learn

  • Distinguish categories from numerical amounts by asking what the recorded values mean.
  • Classify variables whose values are words, labels, or group names.
  • Recognize when digits are codes rather than measurements or counts.
  • Explain why arithmetic summaries of category codes can be misleading.
  • Apply the distinction to variables recorded for the same cases.

Why the Distinction Matters

A data table may contain words, numbers, or both. The appearance of a value alone does not tell us what kind of variable it belongs to. A value such as “blue” may identify a group, while a value such as 12 may describe an amount. But 12 could also be a label assigned to a group. To choose sensible ways to organize or summarize data, we first need to ask what the values represent.

This distinction is basic to statistical thinking. For a categorical variable, the values sort cases into groups. For a quantitative variable, the values express amounts, so differences between values have numerical meaning. The test is about the meaning of the values, not whether they are written as words or digits.

Definition: A categorical variable records which group or category a case belongs to. Its values function as labels. A quantitative variable records a numerical amount or count, so comparing numerical differences between its values is meaningful.

The terms describe variables, not individual entries. For example, “department” is a categorical variable, and “Biology” is one of its values. “Travel time in minutes” is a quantitative variable, and 18 is one possible recorded value. In each case, the variable is the characteristic being recorded across cases; its values are the observations of that characteristic.

A Practical Classification Test

When classifying a variable, ask what an entry tells you. Does it name or identify a group, or does it express an amount? Then check whether comparing differences between its values makes sense. If the values are amounts, a difference such as 20 minus 12 represents a meaningful numerical difference. If the values are category labels, subtracting one label from another does not describe a difference in amount.

This test also helps with numerical-looking values. A variable may be recorded using digits even though those digits stand for groups. The digits do not become quantitative just because a computer can add them. What matters is whether they represent amounts, rather than serving as labels.

Worked Example: Classifying Variables in a Clinic Record

Imagine a hypothetical clinic recording three variables for each appointment: the type of appointment (routine, urgent, or follow-up), the waiting time in minutes, and the room number assigned. Classify each variable and explain the role of its values.

Type of appointment. The values routine, urgent, and follow-up place appointments into groups. They are category labels, so appointment type is categorical.

Waiting time. The values, such as 8 minutes or 23 minutes, describe amounts of time. The difference between 23 and 8 minutes is 15 minutes of additional waiting, so waiting time is quantitative.

Room number. A room number, such as 12, identifies a room; it does not mean an appointment has 12 units of room. Arithmetic on room numbers would not describe an amount. In this context, room number is categorical.

The fact that one variable is written with digits does not make it quantitative. The room number serves as a label, while the waiting time records an amount.

Numbers Can Be Category Labels

A common source of confusion is a variable whose categories have been assigned numerical codes. For example, a hypothetical survey might record preferred mode of travel using 1 for bus, 2 for bicycle, and 3 for walking. These digits stand in for group names. Changing the coding—for example, using 10 for bus, 20 for bicycle, and 30 for walking—would not change which respondents chose each mode. The variable is still categorical.

By contrast, suppose the survey records the number of minutes each person spends travelling. Values such as 10, 20, and 30 represent amounts of time. The difference between 30 and 10 is 20 minutes, regardless of which particular people had those values. That variable is quantitative.

A useful check is to imagine changing the numerical labels while keeping all group memberships exactly the same. If that change alters a proposed numerical summary, but does not alter the underlying cases or groups, the summary may depend on arbitrary coding rather than meaningful amounts.

Worked Example: Do the Digits Represent Amounts?

In a hypothetical questionnaire, respondents select one of three study locations. The data are recorded as 1 for library, 2 for home, and 3 for café. A researcher says the average location code is 1.8 and treats it as a measure of where respondents tend to study. Is the variable quantitative?

No. The choices library, home, and café are groups. The codes 1, 2, and 3 are labels for those groups, not amounts. The numerical order does not establish that café is “more” than home or that the difference between library and home equals the difference between home and café.

The coding can be changed without changing any respondent’s choice. Suppose four hypothetical responses are library, library, home, and café. With the original coding, the mean code is \( (1+1+2+3)/4=1.75 \). If the same categories are coded 10 for library, 20 for home, and 30 for café, the mean code becomes \( (10+10+20+30)/4=17.5 \).

The category counts have not changed, but the mean has changed because the numerical labels changed. Neither mean describes a meaningful average location. The variable is categorical, and a meaningful summary would report the number or proportion of responses in each category.

Amounts, Counts, and Group Membership

Quantitative variables include measurements and counts when the recorded values represent amounts. Examples include distance in kilometres, number of books borrowed, and the number of minutes spent waiting. In each case, the value is intended to convey how much or how many, rather than identify a group.

Categorical variables include group membership recorded with words or codes. Examples include a participant’s assigned study group, the material type of a manufactured item, or a selected transportation mode. Even when the groups have a natural order, the values still describe categories if they are being used as group labels. Whether categories have an order is a separate question from whether the variable measures an amount.

Some data can be recorded in more than one way, so classification depends on what was actually asked and recorded. “Age in years” records an amount of time lived and is quantitative. “Age group,” with values such as “under 18,” “18–29,” and “30 or older,” records membership in one of several groups and is categorical. The groups describe age, but the recorded variable is the group label, not each person’s exact age.

Worked Example: Separating a Measurement From Its Grouped Version

A hypothetical project records the ages of six volunteers in years: 19, 22, 22, 27, 31, and 38. For a summary table, the project also places each person into one of two age groups: under 30 or 30 and older. Classify both variables.

Recorded age in years. The values are numerical amounts of age. Differences between them are meaningful: the difference between 38 and 22 is 16 years. Age in years is quantitative.

Age group. The values under 30 and 30 and older assign each volunteer to a category. This grouped variable is categorical, even though its categories are based on a quantitative measurement.

For these six hypothetical volunteers, four are under 30 and two are 30 or older. Those group counts describe the categorical age-group variable. The original ages retain more detail: replacing the six ages with two group labels loses the differences among people within each group.

Why the Classification Guides Analysis

The distinction matters because the kinds of summaries that make sense depend on what a variable records. For a categorical variable, it is natural to count cases in each category or report the share in each category. For a quantitative variable, numerical summaries can describe the amount recorded, provided they answer the question of interest. Treating category labels as measurements can produce calculations that look precise but have no useful interpretation.

This is not simply a rule about which software functions to use. Software will calculate an average for many columns of numbers, including codes for categories. The analyst must decide whether the result answers a meaningful question. A successful calculation is not automatically a meaningful statistical summary.

The distinction is also useful when a data set contains several variables for the same cases. A hypothetical school record might include each student’s program of study and the number of hours spent studying last week. Program of study identifies a group, so it is categorical. Study hours describe amounts of time, so they are quantitative. The same cases can have both kinds of variables; classification is made separately for each variable.

1
Read the variable’s meaning.
Use its description and the way it was collected, not just the visual form of its values.
2
Ask what each value represents.
If it identifies a group, the variable is categorical. If it expresses a numerical amount or count, it is quantitative.
3
Check whether differences have meaning.
A difference between amounts can be interpreted in the recorded context. A difference between arbitrary group codes cannot.
4
Choose summaries to match.
Describe categorical values as groups and quantitative values as amounts; do not let a software output decide the variable type.

A Short Justification: Why Code Averages Can Mislead

The problem with averaging category codes follows directly from what the codes mean. Suppose four hypothetical responses consist of three people choosing category A and one choosing category B. Code A as 1 and B as 2. The mean code is \( (1+1+1+2)/4=1.25 \). Now keep all four choices unchanged, but code A as 0 and B as 100. The mean is \( (0+0+0+100)/4=25 \).

Both codings describe exactly the same three responses in category A and one in category B. Yet the averages differ, because the spacing between codes was chosen by the person assigning labels. A valid description of these responses should not change just because arbitrary labels are changed. Therefore, the mean code does not summarize an amount or a meaningful location between categories. The category counts or proportions do describe the observed group membership.

Common Mistakes

  • Assuming every number is quantitative. A digit can be a code for a group. Check what it represents before treating it as an amount.
  • Calling a variable categorical just because some values are words. A variable recorded as categories may be coded with numbers, and a quantitative variable may be described with words in its label. Classify by meaning.
  • Using arithmetic just because software permits it. A computed mean of group codes can depend entirely on an arbitrary coding scheme. Ask whether the result has an interpretation in context.
  • Confusing a quantitative source with a categorical recorded value. Exact age in years is quantitative; a variable that records only age group is categorical.
  • Classifying a whole data set at once. A data set may contain both categorical and quantitative variables. Decide separately for each variable.
Key takeaway: Categorical values identify groups; quantitative values represent amounts. Digits alone do not determine the type. Classify a variable by what its values mean and whether numerical differences between them are meaningful.

Check Your Understanding

For each question, explain your classification by referring to what the recorded values represent.

  1. A hypothetical form records a person’s preferred beverage as tea, coffee, or water. Is the variable categorical or quantitative?
  2. A shop records the number of items in each order. Is this variable categorical or quantitative, and why?
  3. A questionnaire records residence area using codes 1, 2, and 3 for three named districts. Does the use of digits make the variable quantitative?
  4. A project records exact trip duration in minutes and also classifies each trip as short, medium, or long. Classify each variable.
  5. Why can changing the numerical codes assigned to categories make the mean code misleading even when no category memberships change?