Categorical variable

By Jude Wallis · Published

A categorical variable records which group or category an individual belongs to, rather than a numerical measurement.

A categorical variable, also called a qualitative variable, records which group each observational unit belongs to. Its values are names, so the only arithmetic that means anything is counting how many units carry each name. What decides the type is what the values stand for, not what they look like: a variable stored as digits is still categorical when the digits are labels.

Take 250 shoppers, each paying one way: 150 by card, 60 by cash, 40 by phone. That is the whole summary. Three counts adding back to 250, and three proportions, 150/250=0.60150/250 = 0.60, 60/250=0.2460/250 = 0.24 and 40/250=0.1640/250 = 0.16, adding to 1. There is no mean payment method and no standard deviation of one.

The wrong sentence is "the survey stored yes as 1 and no as 2, so the mean answer is 1.4." With 100 people, 60 yes and 40 no, those codes do give (60(1)+40(2))/100=1.4(60(1) + 40(2))/100 = 1.4. Recode yes as 0 and no as 1 and the same 100 answers give 0.4. The number moved because the labels moved and nobody changed their answer, which is exactly what it means for arithmetic on the values to be meaningless.

Ordered categories are still categorical. Small, medium and large have a real order and no measured gap between neighbors, so you can name the most common size and not an average one. One coding is the honest exception: for a two-category variable coded 0 and 1, the mean of the codes is the proportion of 1s, which is a genuine summary. That is a count in disguise, not an average of the labels.

Naming the type is topic 1.2. Tables and summary statistics for one categorical variable follow at 1.3, and its graphs at 1.4, where the bars stand apart because the axis is a list of labels rather than a number line; see histograms vs bar graphs. Unit 3, Inference for Categorical Data: Proportions, is the inference built for exactly this kind of variable.

Where this comes up

21 pages on the site use this term.

More variables and data types terms, or browse the full statistics glossary.