3.2 Variable Flavors

The division between categorical and quantitative variables is not the only one. Often, data scientists further classifiy categorical variables as nominal or ordinal. Likewise, quantitative variables can be classified as discrete or continuous. This next level of classification is chiefly based on the notion of scales of measurement of the variables.

Further classification of variables

Figure 3.1: Further classification of variables

3.2.1 Nominal Variable

A categorical variable is nominal when it results from naming or labeling values that don’t have a natural order. An example of a nominal variable is weapon which has the following values:

[1] "blaster"         "bowcaster"       "force-lightning" "lightsaber"     
[5] "slugthrower"     "spear"           "unarmed"        

Can you order the categories in a “natural” way? Not really. The term nominal according the dictionary means “existing in name only”. Thus, nominal values are just that: names. There is no reason why blaster is better or greater than lightsaber. You could say that you prefer a blaster over a lightsaber but that’s a different variable: personal preference.

Other typical examples of nominal variables are:

  • the sex of a newborn child: e.g. female or male

  • the ethnicity of an individual: e.g. Native-American, African-American, Asian, White

  • ice cream flavors: e.g. chocolate, vanilla, strawberry

  • the numbers on the players’ jerseys of a soccer team: numbers used as identifiers

3.2.2 Ordinal Variable

A categorical variable is ordinal when it results from ordering values into a series of categories when no appropriate numerical scale is available. For example, consider a variable “usage frequency” measured with values never, sometimes, and always. In this case we can order the categories from less usage to more usage, or viceversa.

Some examples of ordinal variables are:

  • size of clothes: extra-small, small, medium, large, extra-large

  • college year: freshman, sophomore, junior, senior

  • spiciness: none, mild, moderate, very

  • jedis ranks: youngling, padawan, knight, master, and grand master

3.2.3 Discrete Variable

A quantitative variable is discrete when it results from counting. To be more precise, a discrete variable takes on zero or a positive integer value. Some examples of discrete variables are:

  • the number of male ewooks in a family with four children (0, 1, 2, 3, or 4).

  • the number of robots per Imperial Star Destroyer

  • the number of moons orbiting around a planet

3.2.4 Continuous Variable

A quantitative variable is continuous when it results from measuring. More technically, a continuous variable theoretically takes on an infinite number of possible values, however, its reported values are subject to the precision or accuracy of the measurement device. Some examples of continuous variables are:

  • the height of an individual
  • the weight of a robot
  • the speed of a starship

3.2.5 Caveat

Keep in mind that not all variables fit neatly and unambiguously into one of the previous classes. For example, the age of an individual could be considered of a discrete variable when it gets reported in (whole) number of years. However, age could also be considered to be continuous when measured in a more granular scale: e.g. days, or hours, or seconds. Moreover, sometimes age is reported into ordered categories such as 0 to 5 years, 6 to 10, 11 to 15, and so on. These values would turn age into an ordinal variable.