Variable Types: Continuous, Discrete, Categorical and Ordinal
A continuous variable can land anywhere in a range, so the monthly change of a traded unit is continuous. A discrete variable takes separated values with nothing in between, so a count of months is discrete. A categorical variable is a label with no order. An ordinal variable is a label with an order but no distance. The type decides which summary is legal, and the mean is the one most often taken anyway.
Fifty months of a made-up traded unit sit below, picked so that every count here can be added up on the back of an envelope. Each count, each label and each rank that follows is built out of those fifty months alone.
Underneath the answer sits one habit worth building before any arithmetic starts. Somebody hands the analyst a column. Before a single thing is computed from it, the question to ask is what kind of quantity is sitting in it. Naming the kind of quantity takes about ten seconds, the naming is almost never done out loud, and every summary taken afterwards depends on getting it right.
Very little is needed to follow the argument. Three things are already built and are used below without being explained again: a record of fifty months of a made-up traded unit, the tally that record is stored as, and the three centres that can be taken of a set of numbers. Everything new is a distinction rather than a formula. Fitting a relationship to a record is covered separately, under fitted relationships.
What is a continuous variable?
A continuous variable can take any value in a range, and between any two values it can take there is always another one. The definition is the whole of it, and the second half of the definition is where the work happens.
The monthly change of the Nakshatra unit is continuous. The Nakshatra unit is an invented traded unitAnything with a price that gets quoted over and over, so a change from one quote to the next can be measured. The identity of the thing bought and sold does not matter here., and its monthly changeHow far a price moved over one month, counted against each hundred rupees it started the month at. Going from Rs 100/- to Rs 106/- across a month is a monthly change of 6.00 per cent. is the one finance word this guide needs. A price can move by 1.30 per cent over a month. The same price can move by 1.37 per cent. The same price can move by 1.3712 per cent, and nothing about a price forbids any of those. Between any two changes there sits a third.
The fifty month record shows only five distinct values, and that is a fact about how the record was written down rather than a fact about the quantity underneath it. Somebody decided to store each month as one of five settings. The price itself was never consulted about that decision and was never restricted by it. Five is a property of the file, not of the world.
Think about a child being measured against a doorframe. The pencil marks land on a few dozen centimetre lines over the years, so the record of that child holds a few dozen values. Nobody believes the child grew in centimetre jumps and stood still in between. The child grew continuously and the doorframe recorded coarsely, and those are two different things that happen to live in one place.
What is a discrete variable, and how is it different?
A discrete variable takes separated values with nothing at all in between them. Not nothing that happened to be recorded. Nothing that can exist.
The counts in the fifty month record are discrete. Stored as a tallyA record kept as how many times each value turned up, rather than as a list of every observation in order. Fifty months become five counts, and the order of the months is dropped., the record reads 5, 9, 25, 8 and 3 months against the five values, and those five counts add to 50. There is no such thing as 8.4 months in a tally. A month cannot be half-counted. Between 8 and 9 there is a genuine hole, and the hole belongs to counting rather than to the recording.
Discrete does not mean small and it does not mean whole numbers only; it means the values are separated, and the gap between them is real rather than a rounding choice. Rupee amounts to the nearest paisa are discrete, and the gap is one paisa. Shoe sizes go in halves, and the gap is half a size. A quantity with ten thousand allowed settings is still discrete if nothing is permitted between two neighbouring settings.
Here is the test that separates the two types, and it fits in one line. Take any two values the variable can show, and ask whether something is allowed to sit between them. If yes, always, the variable is continuous. If there is even one pair with a genuine hole between them, it is discrete.
The tally holds 5, 9, 25, 8 and 3 months. Is a count of months continuous or discrete, and how would it be shown?
What is a categorical variable?
A categorical variable is a label with no order. Two labels, ten labels, a hundred labels, and no defensible way to say which one comes first.
Build one out of the same fifty months. Set a thresholdA stated cut-off used to sort things into groups. The cut-off is chosen by whoever is doing the sorting, and moving the cut-off moves which cases land on which side. at 0.00 per cent and label every month either a fall or not a fall. The months at minus 9.00 per cent are falls and there are 5 of them. The months at minus 4.00 per cent are falls too and there are 9 of them. Add those: 5 plus 9 gives 14 falls. Everything else is not a fall. Adding 25, 8 and 3 gives 36. The two counts come to 50, and every month is accounted for once.
The labels fall and not a fall cannot be added, averaged or ranked. The labels can be counted, and a count is a perfectly respectable summary in its own right. Fourteen and thirty six is a real finding about the record. The finding just is not a measurement.
Trying the average anyway is where the damage is easiest to see. Nothing stops anybody writing fall as 1 and not a fall as 2, then averaging the codes. Fourteen months at 1 and thirty six at 2 gives 14 plus 72, or 86, and 86 over 50 is 1.72. A perfectly clean piece of arithmetic. Nobody could call it wrong to flip the codes, so let a fall be 2 and not a fall be 1. The same fifty months then give 28 plus 36, or 64, and 64 over 50 is 1.28. With 7 and 3 instead, the same record answers 4.12.
| The code that happens to be used | The arithmetic | The average it produces |
|---|---|---|
| A fall is 1, not a fall is 2 | 14 times 1 plus 36 times 2, over 50 | 1.72 |
| A fall is 2, not a fall is 1 | 14 times 2 plus 36 times 1, over 50 | 1.28 |
| A fall is 7, not a fall is 3 | 14 times 7 plus 36 times 3, over 50 | 4.12 |
| The count of falls, under every coding above | 5 plus 9, straight off the tally | 14 |
Three answers, one record, no arithmetic error anywhere. Because an average over a categorical column reports the coding somebody chose rather than anything about the months, the operation is illegal on that type. The count in the last row, by contrast, does not budge whichever codes are used, and that steadiness is what makes it a legitimate summary.
A column holds nothing but the labels fall and not a fall. What is the strongest summary that can legally be taken from it?
What is an ordinal variable, and why is it not just a number?
An ordinal variable is a label that carries an order but no measurable distance between its steps. The ordinal type causes almost all of the trouble, and it causes the trouble quietly.
Rank the same fifty months worst to best in five bands. Band 1 holds the 5 worst months, band 2 holds 9, band 3 holds 25, band 4 holds 8 and band 5 holds the 3 best. The order is defensible and nobody would argue about it. Band 1 sits below band 2, band 2 sits below band 3, and so on up. The column never says how far apart the bands are. Nothing in a rank claims that band 2 minus band 1 equals band 5 minus band 4.
An ordinal column will happily yield a medianThe middle value once everything is sorted, with half the observations on either side. How to compute it and when to prefer it is worked through separately.. Sort the fifty months and look at where the middle lands. The counts run 5, then 14 by the end of band 2, then 39 by the end of band 3. The twenty fifth and twenty sixth months both fall inside band 3, so the median band is 3. The median band was found using the order and nothing else, and using nothing else is precisely why the median is allowed.
Ordinal labels are almost always stored as numbers, so nothing in the file stops them being averaged, and the average is meaningless. The file does not know that 3 is a name. The file sees a number, the software sees a number, the spreadsheet computes happily, and out comes a figure with two decimal places that looks exactly like a measurement.
An everyday version, so the idea lands before the arithmetic does. A cinema hands out first, second and third prize. The order is known. Nobody knows whether second was a whisker behind first and third was miles back, or whether the three finished evenly spaced. Averaging the prize positions of a group of entrants gives 2.4 or 1.8, and no statement about the actual performances comes out the other side.
A column holds bands 1 to 5, worst to best. Can the median of that column be taken, and can the mean?
What do the same fifty months look like written all four ways?
One record, four notations, and none of them adds a single month or removes one. The table below holds the whole distinction in one place, and every figure in it is worked from the tally rather than carried in.
A made-up record allows one statement that a real record never allows. The generatorThe made-up rule that hands out the values, carrying a fixed weight on each one. Since it existed before any month came out of it, what it does on average is a stated fact and never a guess. behind these fifty months was written down before any month was drawn from it, so its true centre of 1.00 per cent and its true spread of 5.00 per cent are known by construction. The record itself reports a mean of 0.50 per cent, half the true centre. The gap between the two is not a mistake in the record. A gap of that size is what fifty months happen to look like, and seeing the gap at all is a luxury a real dataset never offers.
| Written as | What the column holds | What is legal on it |
|---|---|---|
| A continuous measurement | Fifty monthly changes, each of which could in principle have been any value at all | The mean of 0.50 per cent, the spread of 4.97 per cent, the median, the mode and a count |
| A discrete tally | 5, 9, 25, 8 and 3 months against the five values, adding to 50 | Everything above, since the counts themselves are separated numbers with real gaps |
| A categorical column | Fall or not a fall against a threshold of 0.00 per cent, giving 5 plus 9, which is 14, against 25 plus 8 plus 3, which is 36 | A count of each label and the most common label. Nothing else |
| An ordinal column | Bands 1 to 5, worst to best, carrying 5, 9, 25, 8 and 3 months | The median band, which is band 3, plus the counts and the most common band |
| All four | Fifty months, every time | Fewer summaries with each step down the table |
Check the third row yourself rather than taking it: 5 plus 9 is 14, and 25 plus 8 plus 3 is 36, and 14 plus 36 is 50. Check the fourth row too: the running counts reach 5, then 14, then 39, so the twenty fifth and twenty sixth months sit inside band 3 and the median band is 3.
The mean of 0.50 per cent is a point estimateOne number handed over as the whole answer, standing alone, saying nothing about how far off it might be. How wide a range around such a number ought to run is worked out separately. that survives the first two rows and dies in the third, and that is the entire cost of a change of notation. Nothing about the months changed between row two and row three. Only the writing did.
The monthly change shows only five distinct values across this record. Does that make the monthly change a discrete variable?
Which summaries is each type allowed?
Five summaries, four types, and one grid that settles every question of permission in this guide. The rule underneath it is short: each summary needs something from the values, and a type either supplies that thing or does not.
A count needs nothing at all. A count needs only that the values be distinguishable from each other, and every type manages that, so a count works everywhere. The mode, meaning the most common value, needs the same and no more: two entries have to be tellable apart or not, and that is it.
The median needs an order. Finding the middle requires sorting, and sorting a column of fall and not a fall is not possible in any defensible way, so a categorical column has no median. Ordinal, discrete and continuous columns all sort, so all three have one.
The arithmetic mean and the standard deviationA single number describing how far the values sit from their centre on average. The standard deviation is worked out separately. Only its demand on a column matters here. need more than an order. Both operations subtract and add, so both need the distance between values to mean something. A mean adds values together. A standard deviation subtracts each value from the centre. Neither operation makes sense unless a difference of one, anywhere on the scale, means the same amount of the thing being measured.
| Summary | Categorical | Ordinal | Discrete | Continuous |
|---|---|---|---|---|
| A count of each value | Allowed | Allowed | Allowed | Allowed |
| The mode, the most common value | Allowed | Allowed | Allowed | Allowed |
| The median, the middle value | Not allowed | Allowed | Allowed | Allowed |
| The arithmetic mean | Not allowed | Not allowed | Allowed | Allowed |
| The standard deviation | Not allowed | Not allowed | Allowed | Allowed |
| What the summary needs from the values | Only that they can be told apart | An order | A distance that means the same everywhere | |
The single line worth carrying away from this grid is that a mean requires the distance between values to mean something, and on an ordinal column it does not. Everything else in the table follows from that one sentence and from the two weaker requirements above it.
Which of the four types allow a standard deviation, and what does a standard deviation need from the values?
What is destroyed when a measurement becomes a label?
Turning the fifty month record into fall and not a fall leaves 14 and 36. A great deal walked out of the room on the way.
The mean of 0.50 per cent is gone. The spread of 4.97 per cent is gone. The five values are gone. And the month at minus 9.00 per cent now sits in the same box as a month at minus 0.01 per cent, entirely indistinguishable from it. Both months are below the threshold, and the label records nothing beyond that fact.
The last loss is worth pausing on, and it is the one people underestimate. Inside the group labelled a fall, the months run from minus 9.00 per cent to minus 4.00 per cent, a span of 5.00 percentage points. Inside the group labelled not a fall, they run from 1.00 per cent to 11.00 per cent, a span of 10.00 percentage points. The label column does not know either span. The label column knows 14 and 36.
The destruction runs one way: labels can always be built out of measurements, and measurements can never be built back out of labels. This is not a limitation of any particular software or any particular effort. The information is not hidden or compressed. The information was never written down.
A household version makes the one way street obvious. A diary that records every month as an amount can always be revisited later and each month marked good or tight against whatever line is chosen, including a line nobody had thought of at the start. A diary kept as good or tight from the beginning hides which of the tight months was the worst and by how much, and no amount of later thought recovers either.
The fifty measured months become 14 falls and 36 that were not. Which two figures can no longer be computed from what is left?
Before the panel below is touched, an answer is worth committing to. As the threshold moves from 0.00 per cent up to 6.00 per cent, what happens to the mean of the record?
Slide the threshold and watch fifty measurements collapse into two counts.
The panel opens on the split used above: a threshold of 0.00 per cent, giving 14 months below it and 36 at or above. Check that off the tally as 5 plus 9 against 25 plus 8 plus 3. Moving the slider changes where the line is drawn and nothing else. The five measured bars stay exactly where they are, and only their colour reports which side they landed on. The two category blocks in front of them and the strip underneath redraw. The two counts always add to fifty, so the strip in particular always fills. The strip never reports anything about how far apart the months inside each segment were.
Why does anyone throw that away on purpose?
Because labels are cheaper in every way that matters at the moment of collection, and pretending otherwise would leave half the world's records unexplained.
A label is easier to collect. Asking somebody whether the month was a fall gets an answer in a second; asking for the exact change gets a shrug or a wrong number. A label is easier to agree on. Two people will settle on good or tight far faster than they will settle on a figure to two decimal places. And a label is often all that survives from an older file, where somebody long gone recorded a grade because a grade was what the form had space for.
Converting a measurement down to a label is a real decision with a real cost, and the cost belongs in the same sentence as the convenience rather than three paragraphs away from it. The sentence to aim for is something like: these months were recorded as bands because the branch staff could apply bands consistently and could not apply amounts, and the price of that choice is that no mean and no spread exist for this period.
The one salary household again. A household that writes down good month or tight month every month has a record it can actually keep up for years, and keeping it up is worth a great deal. The same household will never afterwards be able to say by how much the tight months were tight. Both halves of that are true at once. The mistake is not the choice. The mistake is forgetting the choice was made, and then quoting an average of the good and tight codes at somebody five years later.
Where this goes wrong: the mean band of 2.90
The older file kept bands, so the record stores every month as a band from 1 to 5, worst to best. A reader opens the record, averages the band numbers and gets 145 over 50, or 2.90. The reader writes it up as a mean band of 2.90.
Nothing in the file objected. The bands were stored as numbers, the software computed happily, and 2.90 with its two decimal places reads exactly like a measurement. The figure is not one. Band 3 covers months at 1.00 per cent and band 2 covers months at minus 4.00 per cent, and 2.90 does not translate back into any monthly change at all. The figure names a position on the numbering, and the numbering was chosen by whoever set up the file.
The cost is a figure with no units that then gets compared across records and across periods as though it had some. A second reader sees 2.90 here and 3.10 in a different record and reports an improvement, without either number having ever measured anything.
A sharper version of the trap sits in these five values, and it has to be said out loud. The five values here are minus 9.00, minus 4.00, 1.00, 6.00 and 11.00 per cent, exactly five percentage points apart at every single step. Under that even spacing the mean band does convert. Working it through, 2.90 maps to minus 9.00 plus 1.90 times 5.00, or 0.50 per cent, and 0.50 per cent is precisely the record's mean. The arithmetic worked. The arithmetic worked because of a property of these particular values that almost no real banding has, and the reader who takes the coincidence as permission has learned the opposite of the lesson.
Test it by changing one thing. Suppose band 5 stood for 31.00 per cent instead of 11.00 per cent. The band column does not change by a single entry, the counts are still 5, 9, 25, 8 and 3, and the mean band is still 2.90. The mean of the months, though, moves to 85 over 50, or 1.70 per cent. One reported figure of 2.90, two entirely different records underneath it.
The fix is to report the median band, band 3, together with the five counts, and to say in plain words that no mean band was available. That sentence looks weaker in a report and is the only one of the three that is true.
A colleague reports a mean band of 2.90 across a record stored in bands 1 to 5. What is wrong with that sentence?
How is the type of a column worked out?
Somebody hands over a file with a column headed grade, or score, or level, and no description. Three questions settle it, in order, and none of them needs any software.
Question one: can two values be subtracted to give something that means anything? If yes, the column is discrete or continuous, and a mean is already allowed. If no, the next question follows.
Question two, asked only when the first answered yes: can a value sit between two neighbouring values? If yes it is continuous, and if there is a genuine hole it is discrete. Question two is the only one that separates those two types. Getting the answer wrong costs very little, and that is why the question comes second.
Question three, asked only when the first answered no: can the values be put in a defensible order? If yes the column is ordinal, and a median and a mode are permitted and nothing above them. If no it is categorical, and counts and a mode are permitted.
A column of numbers answers none of these three questions by itself, and that silence is exactly why the mistake keeps getting made. The numbers 1, 2, 3, 4 and 5 in a file are equally consistent with a measurement, with a rank and with a code for five branches, and the file rarely says which. A credit analyst handed a legacy file of internal grades runs into this on the first afternoon, and the honest move is to go and find whoever set the file up, or, failing that, to report counts and a median and say why.
The same three questions are worth running on a household budget sheet. A column of amounts spent passes question one immediately. A column headed how the month felt, scored 1 to 5, fails question one and passes question three, so it gets a median and never an average, however tempting the spreadsheet makes it.
A column of numbers arrives with no description of any kind. What is the first question that separates a measurement from a code?
Covered elsewhere. No particular summary figure is worked through in depth here. A mean, a median, a mode, a spread and an interval, and when each is the right one to quote, are all covered separately. The shape of a record, meaning how lopsided it is and how heavy its extremes are, is covered separately too. Measurement error, a different problem from a variable of the wrong type, is covered separately, as is how a variable of any type would be used inside a fitted relationship.
Where can any of this be checked?
All of it can be checked here, with a pencil. Every figure underneath is either one of the fifty made-up months or an addition performed on those months in plain view, so nothing needs looking up and nothing can go out of date.
| The figure stated | How that figure was produced | Site | Date read |
|---|---|---|---|
| The five monthly changes and how often each turns up | Written down for teaching before anything was worked out from them. The counts 5, 9, 25, 8 and 3 add to 50 | None. Nothing was retrieved | Not applicable |
| The 14 falls and the 36 that were not | Added here from those counts, as 5 plus 9 against 25 plus 8 plus 3 | None. Addition only | Not applicable |
| The mean of 0.50 per cent and the spread of 4.97 per cent | Computed from the same fifty months and recomputed here rather than carried across | None. Arithmetic only | Not applicable |
| The true centre of 1.00 per cent and true spread of 5.00 per cent | Stated properties of the made-up generator, written down before any month was drawn from it | None. Stated, not measured | Not applicable |
| The four type names themselves | Common property in the study of measurement, stated here without being attached to any one author, because no single attribution is safe without checking the text | None. No document quoted | Not applicable |
The Nakshatra unit and the fifty months recorded against it are invented.
Educational material. Not advice on any investment, tax, budget or market position.
