Basics

Tests for nominal variables

Descriptive statistics

Tests for one measurement variable

Tests for multiple measurement variables

Multiple tests

Miscellany

Types of variables



One of the first steps in deciding which statistical test to use is determining what kinds of variables you have. When you know what the relevant variables are, what kind of variables they are, and what your null and alternative hypotheses are, it's usually pretty easy to figure out which test you should use. For our purposes, it's important to classify variables into three types: measurement variables, nominal variables, and ranked variables.

Armadillidium vulgare
Isopod crustacean (pillbug or roly-poly), Armadillidium vulgare.

Similar experiments, with similar null and alternative hypotheses, will be analyzed completely differently depending on which of these three variable types are involved. For example, let's say you've measured variable X in a sample of 56 male and 67 female isopods (Armadillidium vulgare, commonly known as pillbugs or roly-polies), and your null hypothesis is "Male and female A. vulgare have the same values of variable X." If variable X is width of the head in millimeters, it's a measurement variable, and you'd analyze it with a t-test or a Model I one-way analysis of variance (anova). If variable X is a genotype (such as AA, Aa, or aa), it's a nominal variable, and you'd compare the genotype frequencies with a Fisher's exact test, chi-square test or G-test of independence. If you shake the isopods until they roll up into little balls, then record which is the first isopod to unroll, the second to unroll, etc., it's a ranked variable and you'd analyze it with a Kruskal–Wallis test.

Measurement variables

Measurement variables are, as the name implies, things you can measure. An individual observation of a measurement variable is always a number. Examples include length, weight, pH, and bone density.

The mathematical theories underlying statistical tests involving measurement variables assume that they could have an infinite number of possible values. In practice, the number of possible values of a measurement variable is limited by the precision of the measuring device. For example, if you measure isopod head widths using an ocular micrometer that has a precision of 0.01 mm, the possible values for adult isopods whose heads range from 3 to 5 mm wide would be 3.00, 3.01, 3.02, 3.03... 5.00 mm, or only 201 different values. As long as there are a large number of possible values of the variable, it doesn't matter that there aren't really an infinite number. However, if the number of possible values of a variable is small, this violation of the assumption could be important. For example, if you measured isopod heads using a ruler with a precision of 1 mm, the possible values could be 3, 4 or 5 mm, and it might not be a good idea to use the statistical tests designed for continuous measurement variables on this data set.

Variables that require counting a number of objects, such as the number of bacteria colonies on a plate or the number of vertebrae on an eel, are known as meristic variables. They are considered measurement variables and are analyzed with the same statistics as continuous measurement variables. Be careful, however; when you count something, it is sometimes a nominal variable. For example, the number of bacteria colonies on a plate is a measurement variable; you count the number of colonies, and there are 87 colonies on one plate, 92 on another plate, etc. Each plate would have one data point, the number of colonies; that's a number, so it's a measurement variable. However, if the plate has red and white bacteria colonies and you count the number of each, it is a nominal variable. Each colony is a separate data point with one of two values of the variable, "red" or "white"; because that's a word, not a number, it's a nominal variable. In this case, you might summarize the nominal data with a number (the percentage of colonies that are red), but the underlying data are still nominal.

Something that could be measured is a measurement variable, even when the values are controlled by the experimenter. For example, if you grow bacteria on one plate with medium containing 10 mM mannose, another plate with 20 mM mannose, etc. up to 100 mM mannose, the different mannose concentrations are a measurement variable, even though you made the media and set the mannose concentration yourself.

Nominal variables

These variables, also called "attribute variables" or "categorical variables," classify observations into a small number of categories. A good rule of thumb is that an individual observation of a nominal variable is usually a word, not a number. Examples of nominal variables include sex (the possible values are male or female), genotype (values are AA, Aa, or aa), or ankle condition (values are normal, sprained, torn ligament, or broken). Nominal variables are often used to divide individuals up into classes, so that other variables may be compared among the classes. In the comparison of head width in male vs. female isopods, the isopods are classified by sex, a nominal variable, and the measurement variable head width is compared between the sexes.

Nominal variables are often summarized as proportions or percentages. For example, if I count the number of male and female A. vulgare in a sample from Newark and a sample from Baltimore, I might say that 52.3 percent of the isopods in Newark and 62.1 percent of the isopods in Baltimore are female. These percentages may look like a measurement variable, but they really represent a nominal variable, sex. I determined the value of the nominal variable (male or female) on 65 isopods from Newark, of which 34 were female and 31 were male. I might plot 52.3 percent on a graph as a simple way of summarizing the data, but I would use the 34 female and 31 male numbers in all statistical tests.

It may help to understand the difference between measurement and nominal variables if you imagine recording each observation in a lab notebook. If you are measuring head widths of isopods, an individual observation might be "3.41 mm." That is clearly a measurement variable. An individual observation of sex might be "female," which clearly is a nominal variable. Even if you don't record the sex of each isopod individually, but just counted the number of males and females and wrote those two numbers down, the underlying variable is a series of observations of "male" and "female."

It is possible to convert a measurement variable to a nominal variable, dividing individuals up into a small number of classes based on ranges of the variable. For example, if you are studying the relationship between levels of HDL (the "good cholesterol") and blood pressure, you could measure the HDL level, then divide people into two groups, "low HDL" (less than 40 mg/dl) and "normal HDL" (40 or more mg/dl) and compare the mean blood pressures of the two groups, using a nice simple t-test.

Converting measurement variables to nominal variables ("categorizing") is common in epidemiology and some other fields. It is a way of avoiding some statistical problems when constructing complicated regression models involving lots of variables. I think it's better for most biological experiments if you don't do this. One problem with categorizing measurement variables is that you'd be discarding a lot of information; in our example, you'd be lumping together everyone with HDL from 0 to 39 mg/dl into one group, which could decrease your chances of finding a relationship between the two variables if there really is one. Another problem is that it would be easy to consciously or subconsciously choose the dividing line between low and normal HDL that gave an "interesting" result. For example, if you did the experiment thinking that low HDL caused high blood pressure, and a couple of people with HDL between 40 and 45 happened to have high blood pressure, you might put the dividing line between low and normal at 45 mg/dl. This would be cheating, because it would increase the chance of getting a "significant" difference if there really isn't one. If you are going to categorize variables, you should decide on the categories by some objective means; either use categories that other people have used previously, or have some predetermined rule such as dividing the observations into equally-sized groups.

Ranked variables

Ranked variables, also called ordinal variables, are those for which the individual observations can be put in order from smallest to largest, even though the exact values are unknown. If you shake a bunch of A. vulgare up, they roll into balls, then after a little while start to unroll and walk around. If you wanted to know whether males and females unrolled at the same average time, you could pick up the first isopod to unroll and put it in a vial marked "first," pick up the second to unroll and put it in a vial marked "second," and so on, then sex the isopods after they've all unrolled. You wouldn't have the exact time that each isopod stayed rolled up (that would be a measurement variable), but you would have the isopods in order from first to unroll to last to unroll, which is a ranked variable. While a nominal variable is recorded as a word (such as "male") and a measurement variable is recorded as a number (such as "4.53"), a ranked variable can be recorded as a rank (such as "seventh").

You could do a lifetime of biology and never use a true ranked variable. The reason they're important is that the statistical tests designed for ranked variables (called "non-parametric tests," for reasons you'll learn later) make fewer assumptions about the data than the statistical tests designed for measurement variables. Thus the most common use of ranked variables involves converting a measurement variable to ranks, then analyzing it using a non-parametric test. For example, let's say you recorded the time that each isopod stayed rolled up, and that most of them unrolled after one or two minutes. Two isopods, who happened to be male, stayed rolled up for 30 minutes. If you analyzed the data using a test designed for a measurement variable, those two sleepy isopods would cause the average time for males to be much greater than for females, and the difference might look statistically significant. When converted to ranks and analyzed using a non-parametric test, the last and next-to-last isopods would have much less influence on the overall result, and you would be less likely to get a misleadingly "significant" result if there really isn't a difference between males and females.

Some variables are impossible to measure objectively with instruments, so people are asked to give a subjective rating. For example, pain is often measured by asking a person to put a mark on a 10-cm scale, where 0 cm is "no pain" and 10 cm is "worst possible pain." This is a measurement variable, even though the "measuring" is done by the person's brain. For the purpose of statistics, the important thing is that it is measured on an "interval scale"; ideally, the difference between pain rated 2 and 3 is the same as the difference between pain rated 7 and 8. Pain would be a ranked variable if the pains at different times were compared with each other; for example, if someone kept a pain diary and then at the end of the week said "Tuesday was the worst pain, Thursday was second worst, Wednesday was third, etc...." These rankings are not an interval scale; the difference between Tuesday and Thursday may be much bigger, or much smaller, than the difference between Thursday and Wednesday.

Circular variables

A special kind of measurement variable is a circular variable. These have the property that the highest value and the lowest value are right next to each other; often, the zero point is completely arbitrary. The most common circular variables in biology are time of day, time of year, and compass direction. If you measure time of year in days, Day 1 could be January 1, or the spring equinox, or your birthday; whichever day you pick, Day 1 is adjacent to Day 2 on one side and Day 365 on the other.

If you are only considering part of the circle, a circular variable becomes a regular measurement variable. For example, if you're doing a regression of the number of geese in a corn field vs. time of year, you might treat Day 1 to be March 28, the day you planted the corn; the fact that the year circles around to March 27 would be irrelevant, since you would chop the corn down in September.

If your variable really is circular, there are special, very obscure statistical tests designed just for circular data; see chapters 26 and 27 in Zar.

Ambiguous variables

When you have a measurement variable with a small number of values, it may not be clear whether it should be considered a measurement or a nominal variable. For example, if you compare bacterial growth in two media, one with 0 mM mannose and one with 20 mM mannose, and you have several measurements of bacterial growth at each concentration, you should consider mannose to be a nominal variable (with the values "mannose absent" or "mannose present") and analyze the data using a t-test or a one-way anova. If there are 10 different mannose concentrations, you should consider mannose concentration to be a measurement variable and analyze the data using linear regression (or perhaps polynomial regression).

But what if you have three concentrations of mannose, or five, or seven? There is no rigid rule, and how you treat the variable will depend in part on your null and alternative hypotheses. If your alternative hypothesis is "different values of mannose have different rates of bacterial growth," you could treat mannose concentration as a nominal variable. Even if there's some weird pattern of high growth on zero mannose, low growth on small amounts, high growth on intermediate amounts, and low growth on high amounts of mannose, the one-way anova can give a significant result. If your alternative hypothesis is "bacteria grow faster with more mannose," it would be better to treat mannose concentration as a measurement variable, so you can do a regression. In my class, we use the following rule of thumb:
—a measurement variable with only two values should be treated as a nominal variable;
—a measurement variable with six or more values should be treated as a measurement variable;
—a measurement variable with three, four or five values does not exist.

Of course, in the real world there are experiments with three, four or five values of a measurement variable. Your decision about how to treat this variable will depend in part on your biological question. You can avoid the ambiguity when you design the experiment--if you want to know whether a dependent variable is related to an independent variable that could be measurement, it's a good idea to have at least six values of the independent variable.

The same rules apply to ranked variables. If you put 10 different bandages on a person's arm, rip them off, then have the person rank them from most painful to least painful, that is a ranked variable. You could do Spearman's rank correlation to see if the pain rank is correlated with the amount of adhesive on the bandage.If you do the same experiment with just two bandages and ask "Which hurts worse, bandage A or bandage B?", that's a nominal variable; it just has two possible values (A or B), or three if you allow ties.

Ratios

Some biological variables are ratios of two measurement variables. If the denominator in the ratio has no biological variation and a small amount of measurement error, such as heartbeats per minute or white blood cells per ml of blood, you can treat the ratio as a regular measurement variable. However, if both numerator and denominator in the ratio have biological variation, it is better, if possible, to use a statistical test that keeps the two variables separate. For example, if you want to know whether male isopods have relatively bigger heads than female isopods, you might want to divide head width by body length and compare this head/body ratio in males vs. females, using a t-test or a one-way anova. This wouldn't be terribly wrong, but it could be better to keep the variables separate and compare the regression line of head width on body length in males to that in females using an analysis of covariance.

Sometimes treating two measurement variables separately makes the statistical test a lot more complicated. In that case, you might want to use the ratio and sacrifice a little statistical rigor in the interest of comprehensibility. For example, if you wanted to know whether there was a relationship between obesity and high-density lipoprotein (HDL) levels in blood, you could do multiple regression with height and weight as the two X variables and HDL level as the Y variable. However, multiple regression is a complicated, advanced statistical technique, and if you found a significant relationship, it could be difficult to explain to your fellow biologists and very difficult to explain to members of the public who are concerned about their HDL levels. In this case it might be better to calculate the body mass index (BMI), the ratio of weight over squared height, and do a simple linear regression of HDL level and BMI.

Further reading

Sokal and Rohlf, pp. 10-13.

Zar, pp. 2-5 (measurement, nominal and ranked variables); pp. 592-595 (circular variables).

References

Picture of isopod from Australian Insect Common Names.

Place, A.J., and C.I. Abramson. 2008. Habituation of the rattle response in western diamondback rattlesnakes, Crotalus atrox. Copeia 2008: 835-843.



Return to the Biological Data Analysis syllabus

Return to John McDonald's home page

This page was last revised August 20, 2009. Its address is http://udel.edu/~mcdonald/statvartypes.html. It may be cited as pp. 7-12 in: McDonald, J.H. 2009. Handbook of Biological Statistics (2nd ed.). Sparky House Publishing, Baltimore, Maryland.

©2009 by John H. McDonald. You can probably do what you want with this content; see the permissions page for details.