Tutorials › Regression Analysis (Undergraduate) › Variable Types and Measurement Scales

Data Structure and Variable Preparation · Tutorial 28 of 991

Variable Types and Measurement Scales

Classify variables by their values and measurement scale, then choose summaries and preparation decisions that preserve their meaning.

Beginner 9 min read

What You'll Learn

  • Distinguish quantitative measurements from categories, including categories recorded with numbers.
  • Tell nominal categories from ordinal categories by whether their ordering is meaningful.
  • Recognize binary variables as two-category variables and classify them by their meaning.
  • Distinguish interval and ratio measurements using the presence or absence of a meaningful zero.
  • Identify date-time variables and explain why they should retain their temporal meaning.
  • Match each variable type to suitable summaries and preparation choices.

Why Variable Type Matters

Before summarizing data or preparing a regression analysis, ask what each recorded value means. A value such as 4 might be a measured quantity, a rating, a category code, or a month number. The digits alone do not tell us which. Treating a category code as a measurement, or averaging ratings whose gaps are not known to be equal, can produce a summary that looks numerical but does not answer a meaningful question.

Variable type helps determine which comparisons and summaries make sense. It also guides preparation: a variable may need to retain category labels, preserve an order, represent a meaningful zero, or remain recognizable as a date or time. These are decisions about meaning, not merely about how data are displayed on a screen.

Definition: A quantitative variable records a numerical amount or count for which arithmetic comparisons have meaning. A categorical variable assigns each observational unit to a group. A nominal variable has categories without a natural order; an ordinal variable has categories with a meaningful order. A binary variable has exactly two categories. A date-time variable records a calendar date, clock time, or timestamp and has temporal meaning.

Categories: Nominal, Ordinal, and Binary

A nominal variable distinguishes groups without ranking them. Examples include blood type, department, and mode of travel. The category labels can be words or numbers, but a numerical code does not make the variable quantitative. If a hypothetical clinic records blood type as 1 for A, 2 for B, 3 for AB, and 4 for O, the numbers are labels. A mean code of 2.6 would not describe a meaningful blood type.

For nominal variables, useful summaries include category counts and proportions. These answer questions such as how many units belong to each group or what fraction are in a given group. A mode—the most frequent category—can also be meaningful. Adding category codes or calculating their mean is not meaningful just because the labels are stored as numbers.

An ordinal variable has categories that can be ranked, but the distances between successive categories are not established as equal. For example, a response scale of “poor,” “fair,” “good,” and “excellent” has an order. It does not, by itself, establish that the difference between poor and fair is the same size as the difference between good and excellent. Counts, proportions, and the median category can preserve the order without assuming equal gaps. The mean of numerical codes may be used in some settings only with a defensible additional interpretation; the codes alone do not supply that justification.

A binary variable has exactly two possible categories, such as present/absent or yes/no. It is a special case of a categorical variable. The two categories may be nominal, or they may have an order in a particular context—for example, “not improved” and “improved.” For a binary variable, counts and proportions are informative. If one category is recorded as 1 and the other as 0, the mean of those codes equals the proportion coded 1, provided each observation truly has one of those two values. That arithmetic identity does not make the coding labels measurements of an amount.

Worked Example: Summarizing a Nominal Variable

In a hypothetical set of eight appointment records, the recorded visit type is: routine, urgent, routine, follow-up, urgent, routine, follow-up, routine. Classify the variable and choose an appropriate summary.

Classification. Visit type is nominal: its categories distinguish kinds of visits, and there is no natural ranking in the listed labels.

Counts. Routine appears 4 times, urgent appears 2 times, and follow-up appears 2 times. The total is \(4+2+2=8\), matching the number of records.

Proportions. The routine proportion is \(4/8=0.50\), or 50%. The urgent and follow-up proportions are each \(2/8=0.25\), or 25%. These summaries retain the category meanings and add to \(1.00\).

Preparation choice. Keep the three visit types as distinct categories. A numerical code assigned to each type would still be a label, so calculating an average of those codes would not summarize the records meaningfully.

Worked Example: Summarizing an Ordinal Rating

For a hypothetical group of seven customers, a satisfaction item is recorded as poor, fair, good, good, good, excellent, excellent. The categories have the stated order from lower to higher satisfaction. Find the median category and explain why it is defensible.

Classification. This is ordinal because the response categories have a meaningful order, while equal spacing between categories has not been specified.

Median category. The observations are already ordered. With \(n=7\), the middle position is \((7+1)/2=4\). The fourth response is good, so the median category is good.

Why this summary fits. The median uses the ranking and identifies the category at the middle position; it does not require assigning equal numerical distances to the category steps. Counts also provide useful context: poor occurs once, fair once, good three times, and excellent twice.

Preparation choice. Preserve the order of the response categories. Replacing them with codes such as 1, 2, 3, and 4 does not establish equal spacing, so a mean code should not automatically be interpreted as an average amount of satisfaction.

Quantitative Variables and Measurement Scales

For quantitative variables, arithmetic such as differences and averages can be meaningful when the values measure a quantity on a suitable scale. Counts are usually discrete, taking separated values such as 0, 1, 2, and so on. Measurements such as mass or time can vary continuously in principle, even when recorded to a limited precision. This distinction describes the possible values; it does not determine whether the measurement is reliable or whether a particular statistical model is appropriate.

Two common quantitative measurement scales are interval and ratio. An interval scale has meaningful, equally sized differences, but its zero point is not a complete absence of the measured quantity. Temperature in degrees Celsius is an example: a change from 10°C to 20°C is the same size as a change from 20°C to 30°C, but 20°C is not twice as warm as 10°C. A ratio scale has equal differences and a meaningful zero representing none of the quantity, so ratios can also be interpreted. For example, a mass of 4 kilograms is twice a mass of 2 kilograms.

These distinctions affect which comparisons are sensible. For interval measurements, differences and averages can be informative, while ratios to zero may not be. For ratio measurements, both differences and ratios can be meaningful. In either case, summaries still need context and units: an average travel time is expressed in time units, not as a unit-free number.

Worked Example: Distinguishing Interval and Ratio Scales

A hypothetical teaching exercise records temperatures of 10°C, 20°C, and 30°C for three rooms, and masses of 2 kg, 4 kg, and 6 kg for three sample containers. Classify both variables and calculate their means.

Temperature. Celsius temperature is quantitative on an interval scale. Its mean is \[ \bar{x}=\frac{10+20+30}{3}=\frac{60}{3}=20\text{°C}. \] The equal differences make this arithmetic meaningful. However, saying 20°C is twice as warm as 10°C is not justified because Celsius zero is not an absence of temperature.

Mass. Mass is quantitative on a ratio scale. Its mean is \[ \bar{x}=\frac{2+4+6}{3}=\frac{12}{3}=4\text{ kg}. \] The scale has a meaningful zero, so the ratio comparison \(4/2=2\) supports saying that 4 kg is twice 2 kg.

Assumptions and interpretation. These arithmetic summaries assume the listed values are measurements on the stated scales, with comparable units within each variable. The means describe the three hypothetical recorded values; they do not establish a claim about other rooms or containers.

Date-Time Variables

A date-time variable records when something occurred, such as a visit date, a clock time, or a timestamp combining date and time. It is not an ordinary nominal category merely because it may be stored in a formatted string, nor should it automatically be treated as a numeric measurement like height. Dates have temporal order, and differences between timestamps can represent elapsed time when the timestamps have been recorded consistently and the intended comparison is clear.

The representation matters. Calendar dates, clock times, and elapsed durations answer different questions. For instance, “the appointment date” identifies a place in the calendar, while “minutes from check-in to appointment” is a duration. A date’s year number may support a numerical trend question in context, but its value as a calendar label should not be confused with a general amount. When preparing a date-time variable, retain enough information to preserve the question being asked; deriving an elapsed-time variable is appropriate only when that duration is relevant.

A date-time summary should match the purpose. Earliest and latest dates describe the range of observed calendar times. A median date can indicate a middle point in chronological order. For a duration, a mean or median duration may be useful, with its unit stated. These are not interchangeable summaries: averaging formatted calendar labels is not automatically a meaningful substitute for summarizing elapsed durations.

Worked Example: Choosing a Summary for Date-Time Data

In a hypothetical scheduling exercise, three check-in timestamps are 09:00, 09:10, and 09:20 on the same day. The corresponding appointment-start timestamps are 09:15, 09:20, and 09:35. Classify the timestamps and calculate the waiting times and their mean.

Classification. Each recorded timestamp is date-time information. The question, however, asks about elapsed waiting time, a quantitative duration.

Calculate the durations. Subtract each check-in time from its appointment-start time: \(09{:}15-09{:}00=15\) minutes, \(09{:}20-09{:}10=10\) minutes, and \(09{:}35-09{:}20=15\) minutes.

Mean waiting time. For the three hypothetical durations, \[ \bar{x}=\frac{15+10+15}{3}=\frac{40}{3}=13.33\text{ minutes}. \] The mean describes the average elapsed waiting time in these three records. The calculation is appropriate because each pair of timestamps yields a duration in the same unit and the times refer to the same day.

Preparation choice. Preserve the timestamps as temporal values and use a duration when the question concerns time spent waiting. Treating 09:00, 09:10, and 09:20 as ordinary category labels would discard the chronological meaning needed for this calculation.

A Practical Classification Sequence

A short sequence of questions can prevent many preparation mistakes. First, decide whether the values are amounts or group labels. If they are labels, ask whether the categories have a defensible order. If there are exactly two categories, note the binary structure as well. If values represent time on a calendar or clock, recognize their temporal meaning before deciding whether the analysis needs dates, times, or durations.

1
Ask what a recorded value represents.
Is it an amount or count, a group label, or a point in calendar time? Do not classify by appearance alone.
2
For categories, check order and number of levels.
Unranked groups are nominal; ordered groups are ordinal; exactly two categories are binary. A binary variable can also be nominal or ordered according to its meaning.
3
For quantitative values, check the scale.
Ask whether differences are meaningful and whether zero represents none of the quantity. These questions distinguish interval from ratio measurement.
4
Choose a summary that respects the type.
Counts and proportions suit categories; ordered summaries can use ranks; arithmetic summaries suit quantitative values when their scale supports the operation. For temporal data, decide whether the question concerns calendar position or elapsed duration.

Common Mistake: Letting the Storage Format Decide

A frequent error is to assume that numerical storage means quantitative measurement. Suppose a hypothetical file assigns 1 to “morning,” 2 to “afternoon,” and 3 to “evening.” The codes do not make the time-of-day categories quantities: the difference between 1 and 2 is not a measured amount of time, and their mean does not identify a meaningful time period. Similarly, a rating code can preserve an order without proving equal gaps. The correction is to identify what the values mean first, then choose summaries that use only the properties the scale supports.

The reverse error is also possible: a variable recorded as text may still represent a quantity or a date-time value. Its storage format alone does not settle its type. Classification should follow the measurement and the question; preparation should preserve that meaning rather than silently changing it.

Key takeaway: Classify a variable by what its values mean. Use counts and proportions for categories, respect ordering without assuming equal gaps, distinguish interval from ratio quantities, and preserve temporal meaning when working with dates and times.

Check Your Understanding

For each item, classify the variable and identify a sensible summary or preparation choice.

  1. A survey records each participant’s preferred form of transportation as walking, bus, or bicycle. Is the variable nominal or ordinal, and what summaries would be appropriate?
  2. A response is recorded as “never,” “sometimes,” or “often.” What feature makes this variable ordinal, and what assumption would be needed to justify treating its category codes as equally spaced measurements?
  3. A two-category variable records whether a hypothetical item passed inspection. Explain why it is binary and when the mean of a 0/1 coding would equal the proportion that passed.
  4. Explain why a temperature of 20°C is not twice as warm as 10°C, even though Celsius temperature is quantitative.
  5. A data set contains check-in timestamps, and the question concerns how long each person waited. What variable should be summarized to answer that question?