Types of variables
- Concept
Every piece of data has a type: unordered categories, ordered categories, counts or measurements. The type decides the summary and the test.
What it is
A variable is a characteristic recorded for each person in a study. Qualitative (categorical) variables are nominal, with no order, or ordinal, with a natural order; quantitative variables are discrete (counts) or continuous (measurements). Naming the type is the first step of any analysis, because it sets the right summary (proportion, median or mean) and the right statistical test.
Structure
- Qualitative or categorical: nominal and ordinal.
- Quantitative or numerical: discrete and continuous.
- Interval scales (no true zero, such as temperature in degrees Celsius) and ratio scales (a real zero, such as age) are subtypes of continuous data.
Worked example
- Data: a clinic records in 200 patients their sex, pain (none, mild, moderate, severe), emergency visits in the past year and systolic pressure.
- Sex is nominal: 118 of 200 are women, so 118/200 = 0.59 (59%). It is summarised with a proportion.
- Pain is ordinal: it is summarised with the median or the percentage in each category, not with an average of ‘points’.
- Emergency visits is discrete (0, 1, 2…): it is summarised with the mean or the median depending on its shape.
- Systolic pressure is continuous: it is summarised with the mean and standard deviation if it is symmetric.
- To compare two clinics: sex with chi-square, pain with Mann-Whitney and systolic pressure with a t test.
- Reading: the same group of patients yields four types of data, and each needs its own summary and its own test.
Types of variables, their summary and a typical test for comparing two groups
| Type | Example | Summary | Test for two groups |
|---|---|---|---|
| Nominal | Blood group, sex | Counts and proportions | Chi-square or Fisher exact test |
| Ordinal | Tumour stage, pain scale | Median and interquartile range | Mann-Whitney |
| Discrete | Number of admissions | Mean or median depending on shape | t test or Mann-Whitney |
| Continuous | Blood pressure, height | Mean and standard deviation (symmetric) | t test |
Common pitfalls
- Coding categories as numbers (1 = mild, 2 = moderate) does not make them quantitative: averaging those codes means nothing.
- Treating an ordinal scale as continuous is reasonable only when it has many levels and a roughly normal shape.
Test yourself
Think of the answer, then tap the question to see it.
What type of variable is cancer stage (I, II, III, IV)?
Ordinal: the categories are ordered, but the gap between one stage and the next is neither equal nor measurable.
What type of variable is the number of falls in a year?
Quantitative discrete: it is a count of whole numbers.
Why does the type of variable decide the statistical test?
Because each test assumes a scale: proportions are compared with chi-square, means with a t test and ordinal data with rank tests.
What is lost when a continuous variable is dichotomised?
Information and statistical power: two people on either side of the cut-off land in different groups although they barely differ.
Connections
Educational content on epidemiological and statistical methods; the examples use made-up numbers to teach the calculation. Not a clinical or legal guide: current Colombian rules are in the official sources.
Sources: Principles of Epidemiology | Lesson 2 - Section 2 (Centers for Disease Control and Prevention, 2012); Principles of Epidemiology | Lesson 2 - Section 8 (Centers for Disease Control and Prevention, 2012).
Spotted a mistake?We are always improving for the community. Tell us what is wrong and our team will review it.Report a mistake
Representative model, for educational purposes only.
