Grade by Grade
C. Organization of Data for Analysis · Organization of Data for Analysis

Variables and Types of Data

C1.2 C1.3About 65 minutes
Learning goals
  • I can distinguish one-variable (univariate), two-variable (bivariate) and multivariable (multivariate) situations.
  • I can identify explanatory and response variables in a relationship.
  • I can classify data as categorical or numerical (qualitative or quantitative), nominal or ordinal, and discrete or continuous.
  • I can explain how the type of data affects which graphs and statistics make sense.

Words to know

individual (case)
One person, object or event that data describe. Each row of a data table is usually one individual.
one-variable (univariate) data
Data where one variable is studied on its own, such as the heights of a group of students.
two-variable (bivariate) data
Data where two variables are recorded for each individual to study a relationship, such as height and arm span.
multivariable (multivariate) data
Data where three or more variables are studied together, such as house price, size, age and location.
explanatory and response variables
In a relationship, the explanatory (independent) variable may help explain or predict changes in the response (dependent) variable.
categorical (qualitative) data
Data that place individuals into groups or categories, such as favourite sport. Arithmetic on categories makes no sense.
numerical (quantitative) data
Data that are numbers measuring or counting something, so arithmetic such as averaging makes sense.
nominal and ordinal
Nominal categories have no natural order (eye colour). Ordinal categories have a natural order (small, medium, large).
discrete and continuous
Discrete data can take only separate values, usually counts. Continuous data can take any value in an interval, usually measurements.

Not all data are numbers

A Grade 12 class fills in an online questionnaire: province, height, number of siblings, favourite season, time to get to school, and how much they agree that "school should start later." That is six questions, and six different kinds of answer. You can find the mean height. Can you find the mean favourite season? (Hopefully you answered "no".)

Before you can organize or analyse any data, you need to know what type of data you have. The type decides which graphs and which statistics make sense.

Individuals and variables

The individuals (or cases) are the people, objects or events that the data describe. A variable is a characteristic recorded for each individual. In a spreadsheet, each row is usually one individual and each column is one variable.

How many variables at once?

  • One-variable (univariate): you study one variable by itself. What is the typical height of Grade 12 students? How spread out are the heights?
  • Two-variable (bivariate): you study how two variables are related. Do taller students have longer arm spans?
  • Multivariable (multivariate): you study three or more variables together. How does a house's price depend on its floor area, its age and its neighbourhood?

In a relationship, the explanatory (independent) variable is the one that may explain or predict the other. The response (dependent) variable is the outcome. In "Does study time affect marks?", study time is explanatory and marks are the response.

The sibling unit One-Variable Data Analysis analyses univariate data. Two-Variable Data Analysis and Validity analyses bivariate data. Real research (in medicine, economics, ecology) is usually multivariate, which is why university statistics courses go further.

Categorical or numerical?

  • Categorical (qualitative) data sort individuals into categories: province, favourite season, type of pet, yes/no answers.
  • Numerical (quantitative) data are numbers that measure or count: height, number of siblings, mass, temperature.

A useful test: does it make sense to average it? The average height makes sense, so height is numerical. Some numbers are really labels, so they are categorical: jersey numbers, postal codes, phone numbers and student numbers. The average jersey number of a hockey team means nothing.

Nominal or ordinal?

Categorical data come in two kinds:

  • Nominal: categories with no natural order: eye colour, province, favourite sport, mode of transportation.
  • Ordinal: categories with a natural order: T-shirt sizes (S, M, L, XL), ratings (strongly disagree to strongly agree), levels of education, medal colours (bronze, silver, gold).

With ordinal data you can talk about a median category, but the "distance" between categories is not measured. Is the gap from "agree" to "strongly agree" the same as the gap from "neutral" to "agree"? We cannot say.

Discrete or continuous?

Numerical data come in two kinds:

  • Discrete: only separate values, with gaps between them. Usually counts: number of siblings, goals in a game, cars in a parking lot.
  • Continuous: any value in an interval. Usually measurements: height, mass, time, temperature, distance.

Continuous data are always recorded to some precision (height to the nearest centimetre), but the variable itself can take any value.

VariableCategorical(qualitative): categoriesNumerical(quantitative): numbersNominalno natural ordereye colour, provinceOrdinalnatural orderT-shirt size, ratingDiscretecounted, gapssiblings, goalsContinuousmeasured, any valueheight, time
Every variable is either categorical or numerical. Categorical splits into nominal and ordinal; numerical splits into discrete and continuous.
Discrete: number of siblings (only whole numbers)0123456no values in the gapsContinuous: time to run 1 km, in minutes (any value in an interval)456789106.27 min is possible
A discrete variable has gaps between its possible values. A continuous variable can take any value in an interval, such as 6.27 minutes.
Type of dataSensible summariesSensible graphs
Categorical, nominalcounts, percentages, modebar graph, circle graph
Categorical, ordinalcounts, percentages, mode, median categorybar graph in order
Numerical, discretemean, median, mode, range, standard deviationbar graph or dot plot, histogram for many values
Numerical, continuousmean, median, range, standard deviation, quartileshistogram, box plot, stem-and-leaf plot
The type of data decides which statistics and graphs make sense. You will build these graphs in One-Variable Data Analysis.
Worked example

Example 1: Classifying questionnaire variables

Classify each variable from a student questionnaire: (a) province of residence, (b) height in cm, (c) number of people living in your home, (d) favourite season, (e) how much you agree that "school should start later" (strongly disagree, disagree, neutral, agree, strongly agree), (f) time to travel to school in minutes, (g) postal code, (h) number of text messages sent yesterday.

  1. Ask first: is it a category or a number that measures or counts?
  2. (a) province: categorical, nominal (no order).
  3. (b) height: numerical, continuous (a measurement).
  4. (c) people in your home: numerical, discrete (a count).
  5. (d) favourite season: categorical, nominal. (The seasons come in a cycle, but no season is "more" than another.)
  6. (e) agreement rating: categorical, ordinal (ordered categories).
  7. (f) travel time: numerical, continuous.
  8. (g) postal code: categorical, nominal (a label made of letters and digits).
  9. (h) texts sent: numerical, discrete (a count).

Nominal: a, d, g. Ordinal: e. Discrete: c, h. Continuous: b, f.

Worked example

Example 2: How many variables?

Decide whether each question involves one-variable, two-variable or multivariable data. For two-variable questions, name the explanatory and response variables. (a) What is the median price of a litre of milk in Ontario grocery stores? (b) Is a person's age related to their hours per week of Internet use? (c) How do a used car's age, kilometres driven and brand together affect its price?

  1. (a) One variable (price of a litre of milk) is studied by itself: one-variable.
  2. (b) Two variables per person: two-variable. Age is explanatory; hours of Internet use is the response.
  3. (c) Price depends on three explanatory variables at once: multivariable. Price is the response.

(a) univariate; (b) bivariate, age explains Internet hours; (c) multivariate.

Worked example

Example 3: Same characteristic, different data types

A survey records age in three ways: (i) exact date of birth, (ii) age in whole years, (iii) age group: under 18, 18 to 34, 35 to 64, 65 and over. Classify each and explain one advantage of each.

  1. (i) Date of birth gives age as a continuous quantity (any instant). Advantage: the most precise, so it can be grouped any way later. Disadvantage: more personal, so it raises privacy concerns.
  2. (ii) Age in whole years is discrete as recorded (0, 1, 2, ...). Advantage: simple and precise enough for most uses; means and standard deviations make sense.
  3. (iii) Age group is categorical, ordinal. Advantage: more private and easy to answer. Disadvantage: you cannot compute a mean age, and you cannot regroup it more finely later.

The choice of how to record a variable changes its type. Collect the most precise version you ethically and practically can; you can always group it later, but you can never un-group it.

Two traps

  1. Numbers that are labels (jersey numbers, postal codes, student numbers) are categorical.
  2. Coded categories are still categorical. If a survey records 1 = bus, 2 = car, 3 = walk, the average code (say 1.8) is meaningless.
Just for fun

Riddle: what type of data is the number on a hockey jersey?

Categorical! If you average the jersey numbers of the whole team you get a number nobody is wearing.

Hands-on activity

Pantry data set

You need: 10 items from your kitchen cupboard or fridge (cans, boxes, bottles), and paper or a spreadsheet.

  1. Make a table with one row per item and these columns: item name, food group or type (e.g. grain, fruit), country where it was made, mass or volume on the label (g or mL), number of servings per package, price if you know it, and your own rating (dislike / okay / like / love).
  2. Fill in the table for all 10 items. Use the label to read the information.
  3. Under each column, write its type: categorical nominal, categorical ordinal, numerical discrete or numerical continuous.
  4. Pick one numerical column and find its mean. Pick one categorical column and find its mode.
  5. Write one one-variable question and one two-variable question your table could help answer.

What to look for: type and country are nominal; rating is ordinal; servings per package is usually discrete (though labels sometimes say "about 2.5"); mass, volume and price are treated as continuous. A good two-variable question: "Do bigger packages cost less per 100 g?"

Your turn

1

Classify: the colour of a car.

2

Classify: the number of maple trees on each street in a neighbourhood.

3

Classify: the mass of a newborn baby.

4

Classify: the result of a restaurant inspection (pass, conditional pass, closed).

5

Classify: a student number such as 345 882 117.

6

Is "Does the temperature affect the number of people at an outdoor rink?" a one-variable or two-variable question? Name the explanatory variable.

7

Give one example of multivariable data.

More practice: warm-up

1

Is favourite pizza topping categorical or numerical?

2

Is the number of goals in a hockey game discrete or continuous?

3

Is the time to finish a test discrete or continuous?

4

Give an example of ordinal data.

5

Another word for categorical data is ____ data.

More practice: on your own

1

A survey codes "How do you get to school?" as 1 = walk, 2 = bus, 3 = car, 4 = bike. The mean code is 2.3. What is wrong with reporting this?

2

Shoe size (for example 8, 8.5, 9) uses numbers. Is it discrete or continuous? Explain.

3

Identify the explanatory and response variables: "Do students who sleep more get faster reaction times?"

4

Which summary makes sense for ratings recorded as poor, fair, good, excellent: the mean, the median category, or neither?

5

Classify each and say what graph suits it: (a) the number of pets per household for 200 households, (b) the type of pet owned.

Challenge

1

Temperature in °C is numerical. Explain why "20°C is twice as warm as 10°C" is not a sensible statement, even though 20 = 2 × 10.

2

A researcher wants to study how commuting affects sleep. Design a set of four variables she could record for each person, with at least one of each: categorical nominal, categorical ordinal, numerical discrete, numerical continuous.

3

Explain why a multivariable study can reach a different conclusion from a two-variable study of the same data. Use the example of ice-cream sales and sunburns.

Check your understanding

Quiz

1.

Which variable is categorical, ordinal?

2.

Which variable is numerical, continuous?

3.

Why are jersey numbers categorical data?

4.

A study asks whether a person's age is related to their hours per week of Internet use. What kind of data is this?

5.

In "Does the amount of fertilizer affect tomato yield?", the response variable is:

6.

The number of customers entering a store each hour is:

For parents and teachers

Big idea (C1.2, C1.3): before analysing data, identify how many variables are involved and what type each one is. The type decides which graphs and statistics make sense.

How to help: Point to everyday items and ask "What type of data is that?": the number on a bus route (categorical label), the price at the gas pump (numerical, continuous), the number of people in line (discrete), a restaurant's star rating (ordinal).

Common difficulties:

  • Calling anything with digits "numerical". Postal codes, phone numbers and coded answers are categorical.
  • Confusing discrete and continuous. Ask: is it counted (discrete) or measured (continuous)?
  • Forgetting that ordinal data have an order, which allows a median category but not a meaningful mean.
  • Mixing up explanatory and response variables. The response is the outcome you want to explain.