Analysis of Covariance (ANCOVA)

(Please use the links below to navigate this page)






This page explains how to perform an analysis of covariance (ANCOVA) and to interpret the results of this test. Some of the text that follows assumes that you already have a familiarity with two-factor ANOVA, so if you have not already done so it is recommended that you read the web page dedicated to that technique before proceeding further.

ANCOVA used to compare the means of two or more samples when there is at least one categorical independent variable and also at least one continuous independent variable (a covariate) that may also affect your data. At its most basic level it can be thought of as equivalent to a two-factor ANOVA except for the fact that one of the two independent variables is continuous rather than categorical. It can also be thought of as a combination of a one-factor ANOVA and a linear regression in one analysis. For example, a clinical study comparing the effects of two pharmaceuticals on blood cholesterol concentration (BCC) might also measure the body mass index (BMI) of all the patients in the study, in case this also affected BCC. Here, pharmaceutical type would be the categorical independent variable and BMI would be the covariate.

Back to the top



As with two-factor ANOVA, ANCOVA can test for interactions between the independent variables. Consider a hypothetical study of flower production in two subspecies of plants. The number of flowers per plant might vary between subspecies, but within each subspecies flower production might also vary with individual plant size, and this relationship might be positive or negative. A positive relationship might arise if plants with more resources (sunlight, water, nutrients) were able to invest more energy into both growth and flower production. A negative relationship might arise if there was a trade-off between energy invested in growth and energy invested in flower production. In this study, subspecies is a categorical variable and plant size is a continuous variable (the covariate). Measuring plant size as well as flower production in the two subspecies allows investigation of three different questions:

  1. Is flower production influenced by subspecies?
  2. Is flower production influenced by plant size?
  3. Is the effect of flower production on plant size influenced by subspecies?

As with two-factor ANOVA, the effect of subspecies on flower production is referred to as a main effect (Question 1). The effect of plant size (Question 2) is normally referred to as a covariate effect, although some statisticians refer to all effects that are not interactions (including covariate effects) as main effects. Again, in a similar way to two-factor ANOVA, there might also be an interaction effect, in which the effect of flower production on plant size is influenced by which subspecies is being studied (Question 3). However, the nature of the interaction effect differs between two-factor ANOVA and ANCOVA. With two-factor ANOVA the interaction is between two categorical variables, whereas with ANCOVA the interaction is between one categorical and one continuous variable.

The presence or absence of an interaction effect in an analysis of covariance can be illustrated graphically with reference to some possible outcomes of the above study. One possibility is illustrated below:

ANCOVA graph1

In this example, flower production is positively correlated with plant size (as measured by height) and, on average, plants of subspecies 2 produce more flowers than those of subspecies 1. However, the relationship between flower production and plant size is more or less the same for both subspecies; i.e., regression lines fitted to the two samples would be approximately parallel. This means that there is no interaction between the two variables.

Contrast the above with a second possible experimental outcome:

ANCOVA graph2

In this example, as in the first, flower production is positively correlated with plant size and, on average, plants of subspecies 2 produce more flowers than those of subspecies 1. However, in contrast to the first example, the relationship between flower production and plant size is not the same for the two subspecies. Flower production increases faster with plant height in subspecies 1 than in subspecies 2, and regression lines fitted to the two samples would not be parallel. This means that there is an interaction between the two variables – in this case a non-crossing interaction because although the regression lines are not parallel, the trend is the same for both (a positive correlation).

Finally, consider a third possible experimental outcome:

ANCOVA graph3

Here, flower production decreases with plant size in subspecies 1 but increases with plant size in subspecies 2. The trends are in opposite directions in the two subspecies, so this is an example of a crossing interaction. Moreover, unlike in the previous two examples, it is not possible to make a general statement about differences between the two subspecies: when comparing small plants, subspecies 2 tends to produce more flowers than species 1, but when comparing large plants the opposite is true, and at intermediate sizes the two subspecies produce approximately the same number of flowers.

Back to the top



A central question in plant reproductive ecology is how hermaphroditic plant species allocate resources to male vs. female structures. One study carried out to address this question counted the number of stamens (male structures that produce pollen) and ovules (female structures that when fertilized by a pollen grain will mature into seeds) in the flowers of prairie larkspur plants in two populations in southeastern Minnesota. They also counted the total number of flowers produced by each plant to determine whether plant size affected ovule production per flower.

ANCOVA is the appropriate statistical test for this study because there is one categorical independent variable (study site) and one continuous independent variable (plant size, as measured by total flower production).

Three null hypotheses can be tested with these data:

  1. There is no difference in mean ovule number per flower between the two populations (main effect)
  2. There is no effect of plant size on mean ovule number per flower (covariate effect)
  3. The effect of plant size on mean ovule number per flower does not differ between study sites (interaction effect)

Download the following data file and import it into JMP: Larkspur ANCOVA Excel file

The analysis can be performed in JMP as follows:

  • Before starting the analysis, change Plant from a continuous to a categorical variable. The numbers in the column identify individual plants in each population, and JMP interpreted these numbers to mean that Plant is continuous variable. However, in reality it is categorical: the numbers are simply an identification code and could just as easily have been letters. Double click on the variable name box at the top of the column and in the pop-up window change Data Type to Character (the Modeling Type will automatically change to Nominal), then hit OK. The symbol next to Plant in the Columns list on the left will change from a blue triangle to a red histogram. Although we will not be using Plant as a variable in our analysis it is always a good idea to properly code all variables in a JMP file.
  • A useful feature in JMP that will help visualize the output of this analysis is to color code the levels of the categorical variable (Population). From the Row menu, select Color or Mark by Column. In the pop-up window highlight the Population variable, choose a color pattern from the Colors menu (JMP Default will be used in this example) and click on the Save to Column Property box. On the JMP data file, the St. Croix labels will be colored blue and the Cedar Creek labels will be colored red. There will also be a set of blue and red dots in the line number column on the left.
  • From the Analyze menu select Fit Model, then click or drag Mean Ovules into the Y box and both Population and Total Flowers (in that order) into the Construct Model Effects box. To add the interaction effect, highlight Population in the Construct Model Effects box and Total Flowers in the Columns box and then click on Cross.
  • Hit Run
  • As with the one-factor and two-factor ANOVAs that used the Fit Model option, the output window shows a series of figures as well as several summary tables. Most of these have uses beyond the scope of this website. Close the Actual by Predicted Plot, the Residual by Predicted Plot, and the Effect Summary, Lack of Fit and Parameter Estimates tables by clicking on their grey arrows. You can also close the three Leverage Plots by clicking on their grey arrows too.
  • Click on the grey arrow to open the Effect Tests table. Also click on the red arrow next to Population and select LS Means Plot. Depending on whether you are using a Mac or a PC, you may also need to click on the Regression Plot figure to show the colors of the data points. The window will now look like this:

Larkspur ANCOVA output image

To download a high resolution version of this image, click here:  Larkspur ANCOVA output image download

As with one-factor and two-factor ANOVA, the most important pieces of information in this window are as follows:

  • In the Summary of Fit table the R2 value (RSquare = 0.2048) tells us that approximately 20% of the total variation in the dependent variable (mean ovule number per flower) can be explained by the three effects under consideration: Population, Total Flowers, and their interaction. The total sample size is also given (79).
  • The Analysis of Variance table gives the group mean square for all three effects together (the Model row) and the error mean square (the Error row), the ratio of the two (F Ratio) and the associated p-value (Prob > F = 0.0006). Since the p-value is well below the normal threshold for statistical significance (0.05), we can conclude that the three effects together do have a significant effect on ovule number. However, this information alone does not tell us which of the three individual effects are responsible for the overall significance of the test.
  • More usefully, the Effect Tests table shows the degrees of freedom (DF), F Ratio, and p-value (Prob > F) for each of the three effects individually. Here we can see that all three effects are statistically significant (all p-values are < 0.05). Thus, we can reject all three null hypotheses listed above and accept the three alternative hypotheses:
    1. Mean ovule number per flower differs between the two populations
    2. Mean ovule number per flower is affected by (increases with) plant size, as measured by total flower production (i.e., there is a covariate effect)
    3. The effect of plant size on mean ovule number per flower differs between study sites (i.e., there is an interaction effect)
  • The nature of the interaction effect can be seen by looking at the Regression Plot, where the blue dots and regression line correspond to the St. Croix population and the red dots and regression line correspond to the Cedar Creek population. You can see that the lines are not parallel: the slope of the St. Croix regression is much steeper than the slope of the Cedar Creek regression. However, the trend is the same in both populations and the two lines barely cross. We can therefore consider this to be a non-crossing interaction.
  • The Least Squares Means Table for the Population effect shows two versions of the mean values for each group: the arithmetic mean (Mean column) and the least squares mean (Least Sq Mean column), along with the standard error of the least squares mean. The least squares mean is a mean value for each group that takes into account the effects of other variables in the analysis and controls for differences in sample size among the groups of the categorical variable. Note that the two means are not the same. If you were to report mean values for the main effects of an ANCOVA in a paper, you would normally report least squares means, not arithmetic means. In an ANCOVA, the least squares means are the predicted mean values for each group at the average value of the covariate: in this case for plants with 16.0253 flowers.
  • The LS Means Plot show the least squares means for the two populations and their standard errors. You can see that the significant Population effect in the Effect Tests table is due to the fact that plants from the St. Croix population had more ovules per flower than plants from the Cedar Creek population (after controlling for variation in total flower number).

 Back to the top