Quantitative and qualitative variables
Before choosing any statistical method, you need to know what kind of variable you are working with. The type of variable determines which plots make sense, which summary statistics apply, and which tests are valid.
Overview: the two main types
Every variable you measure falls into one of two broad categories:
- Quantitative variables: the observations are numbers that represent a measurable quantity. You can do arithmetic with them (add, average, subtract).
- Qualitative variables (also called categorical): the observations are categories or labels. Arithmetic does not make sense on them.
Each category splits further into two subtypes:
Figure 1: Classification of statistical variables
Quantitative variables
A variable is quantitative when its values are numbers that carry a real magnitude. You can compute a mean, a sum, or a difference and the result is meaningful.
Quantitative variables split into two subtypes depending on the set of possible values.
Discrete variables
A discrete variable can only take values from a finite or countably infinite set, typically whole numbers. You cannot have 2.7 children or 4.3 goals in a football match.
ℹ️ Examples of discrete variables
- Number of commits in a Git repository on a given day.
- Number of support tickets opened per week.
- Number of goals scored in a football match.
- Number of defective items in a production batch.
Figure 2: Goals scored per match in a football season (discrete variable)
Continuous variables
A continuous variable can take any value within an interval. Between any two possible values, there is always another possible value. In practice, the precision is limited by your measuring instrument, but the underlying variable is continuous.
ℹ️ Examples of continuous variables
- Time to complete a 10 km race (could be 42:17.3 or 42:17.31…).
- Daily rainfall in millimeters.
- Blood glucose level in mg/dL.
- Processing time of a server request in milliseconds.
Figure 3: Distribution of server response times (continuous variable)
⚠️ A common trap: numbers that are not quantitative
Not every variable that looks like a number is quantitative. A zip code, a phone number, or a player’s jersey number are stored as numbers but you cannot meaningfully average them. The test: does the average make sense? The average zip code of your customers is not a useful concept. These are nominal variables in disguise.
Qualitative variables
A variable is qualitative when its values are categories or labels, not measurable quantities. The two subtypes differ in whether the categories have a natural order.
Nominal variables
Nominal variables have categories with no natural order. There is no sense in which “red” is greater than “blue”, or “Madrid” is greater than “Barcelona”.
ℹ️ Examples of nominal variables
- Blood type (A, B, AB, O).
- Operating system used (Windows, macOS, Linux).
- Payment method (cash, card, transfer).
- Country of birth.
Figure 4: Operating system market share (nominal variable)
Ordinal variables
Ordinal variables have categories with a meaningful order, but the distances between categories are not necessarily equal or measurable. Knowing that “Excellent” is better than “Good” tells you nothing about how much better.
ℹ️ Examples of ordinal variables
- Pain level on a scale from 1 to 10 (used in medicine).
- Net Promoter Score category (Detractor, Passive, Promoter).
- Academic grade (Fail, Pass, Merit, Distinction).
- Spicy level of a dish (mild, medium, hot, extra hot).
Figure 5: Customer satisfaction survey results (ordinal variable)
⚠️ Ordinal vs nominal: the most common confusion
The key question is: does the order matter? Satisfaction levels (poor, fair, good) are ordinal because the ranking is meaningful. Eye color (brown, blue, green) is nominal because no color ranks above another. A common exam mistake is treating any multi-category variable as nominal without checking whether the categories have a natural order.
Quick reference
| Type | Subtype | Values | Example |
|---|---|---|---|
| Quantitative | Discrete | Whole numbers, countable | Goals per match |
| Quantitative | Continuous | Any value in an interval | Response time (ms) |
| Qualitative | Nominal | Categories, no order | Operating system |
| Qualitative | Ordinal | Categories, with order | Satisfaction rating |