Variables: What Each Row Records
How to name the observational unit and the variables in any data set, tell categorical from quantitative and discrete from continuous, and keep parameters and statistics apart.
Before you summarize any data, say what one row describes and what each column records. The row is the observational unit. Each column is a variable. The type of each variable decides which graphs and summaries make sense, so sorting variables correctly comes before everything else.
1Observational units and variables
An animal shelter keeps a record for each dog it takes in. Every record lists the same things: the dog’s size, whether it has been vaccinated, its age, its weight, and how many days it has been at the shelter.
The observational unit is the item or individual that a datum is collected from. In the shelter’s records it is one dog. In other data sets it could be one student, one drink sold, one day of weather, or one tweet.
A variable is a characteristic that can change from one observational unit to another. Weight is a variable because Moose weighs 71.2 pounds and Pepper weighs 12.6 pounds. A value is what one unit has for that variable: “12.6 pounds” is a value of the variable weight.
A coffee shop’s order log
A coffee shop’s register saves a line for every drink it sells: the drink size (small, medium, large), the price in dollars, the number of add-ons (extra shot, syrup, and so on), and the number of seconds the barista took to make it.
What is the observational unit? What are the variables?
- 1Ask what one line of the log describes. Each line is one drink sold, so the observational unit is one drink.
- 2Each piece of information that changes from drink to drink is a variable: size, price, number of add-ons, and time to make.
- 3Name each variable with its units when it has them: price (dollars), add-ons (a count), time (seconds). Size has no units; its values are labels.
“Large” is not a variable; it is one value of the variable size. “Yes” is a value of vaccinated. If you can ask “what was it for this dog?” and get an answer, you are naming a variable. The answer is a value.
2Categorical or quantitative?
Variables come in two main types.
- A categorical variable takes values that are category names or group labels: small, medium, large; yes or no; biology, art, history. It is also called a qualitative variable.
- A quantitative variable takes numerical values that measure or count something, and it usually has units: pounds, years, days, dollars. It is also called a numerical variable.
The tricky cases are numbers that are really labels. A quick test: would an average make sense? The average age of five dogs means something. The average of five zip codes does not.
| Variable | Values look like | Type | Why |
|---|---|---|---|
| Zip code | 60614, 10027 | Categorical | It names a place. Bigger is not “more.” |
| Jersey number | 7, 23, 99 | Categorical | It identifies a player. |
| Phone area code | 312, 415 | Categorical | A label for a region. |
| Shoe size | 8, 8.5, 9 | Quantitative | It measures foot length on a scale. |
| Rating from 1 to 5 stars | 3, 4, 5 | Usually treated as quantitative | Higher means better, and averages of ratings are common. Say how you are treating it. |
A variable is not quantitative just because its values are digits. Zip codes, ID numbers, and jersey numbers are categorical. Check whether the numbers measure or count something before you average them or draw them on a number line.
3Discrete or continuous?
Quantitative variables split one more time.
- A discrete variable takes a countable number of values, usually because it comes from counting: days at the shelter, goals scored, siblings. The list of possible values can be finite (0 to 10) or go on forever like the whole numbers, but there are gaps between the values.
- A continuous variable can take any value in an interval, usually because it comes from measuring: weight, time, height, temperature. Between any two possible values there is always another one.
| Discrete (counted) | Continuous (measured) |
|---|---|
| Number of texts sent today | Length of a phone call |
| Number of pets at home | A dog’s weight |
| Points scored in a game | Time to run 100 meters |
| Number of cars in a parking lot | Amount of gas in a car’s tank |
A stopwatch might show 12.4 seconds, but the runner’s real time could be 12.4381 seconds. Recording a measurement to the nearest tenth does not change what kind of variable it is. Time is still continuous. Ask whether the quantity itself is counted or measured.
A school club sign-up form
A sign-up form asks for: (a) whether the student plays a school sport; (b) home zip code; (c) number of clubs already joined; (d) height in centimeters; (e) favorite subject; (f) time to walk to school, in minutes.
Is each variable categorical or quantitative? If quantitative, is it discrete or continuous?
- 1(a) Plays a sport: the values are yes and no, which are labels. Categorical.
- 2(b) Zip code: digits, but they only name an area. Averaging two zip codes gives nonsense. Categorical.
- 3(c) Number of clubs: counted: 0, 1, 2, and so on. Quantitative, discrete.
- 4(d) Height: measured, and any value in a range is possible, such as 167.4 cm. Quantitative, continuous.
- 5(e) Favorite subject: the values are names like biology or art. Categorical.
- 6(f) Walking time: measured on a clock. Even if it is written to the nearest minute, the time itself can be any value. Quantitative, continuous.
4Parameters and statistics
Once you have values for a variable, you can summarize them with one number: a mean, a percent, a largest value. What that summary is called depends on where the data came from.
- A parameter is a number that summarizes a variable for the whole population. It is one fixed number, but it is usually unknown, because measuring the whole population is rarely possible.
- A statistic is a number that summarizes a variable for a sample. You can calculate it, because you have the sample’s data.
A statistic is usually not equal to the parameter. Each sample contains different units, so each gives a slightly different statistic. That is not a mistake; it is what samples do. The statistic is still useful: it is the evidence you use to make a statement about the parameter you cannot see.
Four sentences
Decide whether each number is a parameter or a statistic.
- All 312 seniors at a school took the same reading test, and their mean score was 74.
- In a survey of 1,500 adults in a state, 58% said they recycle every week.
- The city’s records show the mean age of all registered voters in the city is 46.2 years.
- A biologist measured 40 frogs from a pond and found that 15% had a spot pattern.
- 1Ask the same question each time: does the number summarize the whole group the sentence is about, or just a part of it?
- 21. All 312 seniors were tested, so 74 describes the whole population of seniors. Parameter.
- 32. 1,500 adults is a sample of the state’s adults. Statistic.
- 43. Records of all registered voters give the whole population. Parameter.
- 54. 40 frogs are a sample of the pond’s frogs. Statistic.
Who has a pet?
Two classes each choose 100 students at random from the same school of 1,840 and ask, “Do you have a pet at home?” Class A gets 46 yes answers. Class B gets 39. Class B says Class A must have made a mistake. Is that right?
- 1Each class found a statistic: \(46 \div 100 = 0.46\) and \(39 \div 100 = 0.39\).
- 2The two samples contain different students, so they will almost never give the same result.
- 3Both statistics are estimates of one parameter, the share of all 1,840 students with a pet. Neither has to equal it.
- 4Only data on all 1,840 students would give the parameter itself.
“46% of students at the school have a pet” is wrong if only 100 students were asked. The 46% describes the sample. Say so: “46% of the 100 students asked have a pet,” or “an estimated 46% of students at the school have a pet.”
5Data beyond numbers
Data do not have to start as a number or a word in a table. Photographs, sounds, videos, and text all carry information, and each can be turned into variables for each observational unit.
| Raw data | Observational unit | Categorical variable | Quantitative variable |
|---|---|---|---|
| Photos from a wildlife camera | one photo | kind of animal shown | number of animals in the photo |
| Recordings of dogs barking | one recording | breed of the dog | loudness in decibels |
| Videos of free throws | one shot | made or missed | height of the ball at its peak |
| Online product reviews | one review | star rating group | number of words |
Comments on a bike lane
A city collects 300 written comments about a new bike lane. How can the comments become data you can summarize? Name the observational unit and three variables.
- 1Each comment is one observational unit.
- 2Read each comment and record answers to questions you set in advance. Does it mention safety? That is a yes or no variable, so it is categorical.
- 3Is the overall tone positive, negative, or mixed? Also categorical.
- 4How many words does it contain? That is a count, so it is quantitative and discrete.
6Quick reference
| Term | Plain meaning | Shelter example |
|---|---|---|
| Observational unit | The item or individual that each row describes | one dog |
| Variable | A characteristic that can change from one unit to the next | weight |
| Value | What one unit has for one variable | 12.6 pounds |
| Categorical variable | Values are category names or group labels | size, vaccinated |
| Quantitative variable | Values are numbers that measure or count, usually with units | age, weight, days |
| Discrete | Countable values, with gaps between them | days at the shelter |
| Continuous | Any value in an interval | weight |
| Parameter | A summary of a variable for the whole population | mean weight of all dogs the shelter has ever housed |
| Statistic | A summary of a variable for a sample | mean weight of these five dogs |
- What is the observational unit, and what does this variable record about it?
- Are the values labels (categorical) or numbers that count or measure (quantitative)?
- If quantitative: counted (discrete) or measured (continuous)?