Group comparison
ANCOVA (Analysis of Covariance)
Compares group means after statistically holding constant one or more continuous variables that also shape the outcome.
Method summary
Analysis of covariance joins analysis of variance and regression in one model. While the question is still about differences between group means, a continuous variable known to explain the outcome enters the model and the group effect is tested once that variable's share has been set aside. Pre-test scores, age, tenure or last period's revenue are typical covariates. Two gains are expected: where groups started out unalike on the covariate, the comparison rests on fairer ground, and because the variability the covariate explains leaves the error term, the test gains sensitivity. YouReply Analyze fits the model by ordinary least squares, builds the effect table with type II sums of squares, and estimates an adjusted mean for each group with the covariates held at their sample mean.
Which research questions does it answer?
- With pre-test scores held constant, does the difference in final scores between three training formats survive?
- Once household size is controlled for, does the gap in saving behaviour between income groups remain?
- Allowing for participants' age, do recall scores differ across advertising channels?
- Controlling for last period's satisfaction, do branches trying a new service model differ from the rest?
When should you use it?
- When a continuous variable thought to distort the group comparison has been measured and its influence should be taken out of the model.
- When the covariate is known on theoretical grounds to relate to the outcome, rather than being whichever numeric column happened to be available.
- When the covariate was measured before grouping happened, or at a moment grouping could not affect.
- When there are more than two groups. It works with two as well, though a regression with one covariate conveys the same information more readably there.
Required variable types
- Dependent variable: a continuous numeric column. Adjusted means are reported in its units.
- Group column: a column carrying categorical values. It may have more than two categories.
- Covariate: one or more continuous numeric columns. With several covariates selected, each gets its own effect row in the output.
Key assumptions
- The covariate is unaffected by grouping
- The covariate must not be a value that changes as a result of group assignment. Using a variable measured after the intervention removes part of the very effect you wanted to test and shrinks the group difference artificially.
- Linear relationship between covariate and outcome
- The model treats the covariate's influence as linear. If the relationship curves, the adjustment falls short and the adjusted means are biased.
- Homogeneity of regression slopes
- The slope between covariate and outcome should be similar in every group. If one group's slope is steep and another's is flat, comparing a single pair of adjusted means loses its meaning, because the group difference itself depends on the level of the covariate.
- Homogeneity of variances
- The spread of the dependent variable is expected to be similar across groups. When the spreads diverge markedly, the F test becomes less dependable.
- Distribution of residuals
- What the model leaves unexplained should be roughly normally distributed and should show no systematic pattern across levels of the covariate.
How YouReply checks these assumptions
- The covariate is unaffected by grouping: The panel does not check this assumption automatically; the researcher evaluates it.
- Linear relationship between covariate and outcome: The panel does not examine the shape of this relationship inside this method. To inspect it you can run the linear regression or correlation methods separately.
- Homogeneity of regression slopes: The panel does not check this assumption. The fitted model carries no interaction between group and covariate, so differing slopes cannot be tested; you need to justify the assumption from your design or study the relationship group by group.
- Homogeneity of variances: Levene's test runs on every run and its result is reported with an accompanying note. The test is performed on the raw dependent variable, by group. Whatever it returns, the fitted model stays the same: no alternative estimation is substituted, and the result is offered as information only.
- Distribution of residuals: Residual normality is not tested in this method, and the output contains no test or plot of the residuals.
How the analysis is run
- 1Drag your data file into the panel; CSV and Excel files are both read.
- 2In the grid on the Data tab, look over how the table parsed, paying particular attention to numbers that may have arrived as text in the covariate column.
- 3On the Variable tab, set the dependent variable and the covariate to scale level and the group column to nominal, writing value labels there if you need them.
- 4Choose analysis of covariance on the Analysis tab. The data requirements box shows which of your columns satisfy the dependent, group and covariate conditions.
- 5In the parameter form pick the dependent variable, the group column and one or more covariates, then start the analysis.
- 6The result opens as collapsible sections: F, p and partial eta squared for the group effect, a separate effect row per covariate, the Levene block with its note, the group descriptives and the adjusted means.
- 7No method-specific chart is drawn here; the output consists of tables and exports to Excel. The computation credits card names the call and version used.
Statistics and tables produced
- Group effect F and p value
- The values testing whether groups differ once the covariates' share has been set aside. The effect table is produced with type II sums of squares.
- Group and error degrees of freedom
- The group degrees of freedom are one less than the number of categories; the error degrees of freedom are what remains after the group and covariate terms are taken from the number of observations.
- Partial eta squared for the group effect
- The effect size giving how much of the variability left unexplained by the covariates is associated with group membership.
- An effect row per covariate
- A separate F value, p value and partial eta squared for each covariate chosen. This is where you see whether a covariate really explains the outcome.
- Homogeneity of variance block
- The result of Levene's test, run by group on the raw dependent variable, together with its note. The model does not change in response to it.
- Group descriptives and adjusted means
- Observed mean, median, mode, standard deviation and number of observations per group, plus the adjusted mean estimated with the covariates held at their sample mean.
Effect size and confidence intervals
- Partial eta squared (group effect)
- The share of the remaining variability, once the covariates are accounted for, attributed to group membership. The values quoted are 0.01 for a small, 0.06 for a medium and 0.14 for a large effect. The figure belongs to the model with covariates: as covariates shrink the denominator, it can look larger than in a covariate-free analysis of the same data, so eta squared values from the two models should not be read interchangeably.
- Partial eta squared (covariate effect)
- Reported separately for each covariate, it shows how much of the outcome that covariate explains. Where a covariate's effect is close to zero, its contribution is questionable and the analysis may be reaching the same conclusion it would without it.
This method returns no confidence intervals. The adjusted means arrive as point estimates, with no standard error or interval beside them, and none is computed for the group differences or for partial eta squared either. If you need to report the uncertainty around adjusted means, that has to be worked out outside the panel.
Example research question and example result
The numbers below are a representative example, not data from a real study or a real user.
- Research question
- Representative example: a training programme delivered in three formats (in person, live online, self-paced) is compared on final test scores. Because participants' pre-test scores differed somewhat across the formats, the pre-test entered the model as a covariate. There are 132 participants in total, 44 in each format.
- Variables
- Dependent variable: final test score (0-100, continuous) · Group column: training format (in person / live online / self-paced) · Covariate: pre-test score (0-100, continuous)
- Example result
- The observed final score means were 68.4 (SD = 9.8), 71.9 (SD = 8.6) and 66.2 (SD = 10.2). With pre-test means of 52.1, 55.6 and 51.0 respectively, the adjusted means came to 68.7, 70.4 and 67.4. The group effect was F(2, 128) = 4.71, p = .011, partial eta squared = 0.07, and the covariate effect F(1, 128) = 48.35, p < .001, partial eta squared = 0.27. Levene's test gave p = .318.
- Interpretation
- The pre-test explains the final score strongly: its effect size is roughly four times the group effect. With the pre-test controlled, the formats still differ significantly, but the adjustment has narrowed the gap, with the widest spread falling from 5.7 points among the observed means to 3.0 points among the adjusted ones. The reason is that the live online group began from a higher pre-test level. Levene's test supports homogeneity of variance, and that note is informational: the model was fitted the same way regardless of the outcome. Which two formats differ on their adjusted means cannot be read from this output.
Real output on a sample dataset
The results below were produced by the analysis engine from this data file. Changing the variable changes the research question as well; every run was computed in advance, so the page sends no request to the engine.
General customer survey (synthetic)
A wide survey of three hundred respondents: two and three category grouping variables, continuous measures, a five point ordinal scale, a binary purchase outcome, a four category brand choice, three repeated measurements, paired binary questions, three raters, four price questions and deliberately empty cells.
- Rows
- 300
- Columns
- respondent_id, gender, education, region, age, income, satisfaction, service_score, price_score, quality_score, loyalty, nps_score, purchased, brand_choice, satisfaction_level, pre_score, post_score, measure_1, measure_2, measure_3, use_before, use_after, use_followup, rater_1, rater_2, rater_3, price_too_cheap, price_cheap, price_expensive, price_too_expensive, feedback_score, followup_rating
The data is synthetic: it comes from a fixed random seed, not from a real study. The values below were produced by the analysis engine from this file, so uploading the same file to the panel gives the same results.
Research question: Does satisfaction differ by education level once age is held constant?
- Dependent variable
- satisfaction
- Grouping variable
- education
- Covariates
- age
- F statistic
- 0.680
- p value
- 0.507
- Degrees of freedom (groups)
- 2
- Degrees of freedom (error)
- 296
- Partial eta squared
- 0.005
- dependent_var
- satisfaction
Descriptive statistics
| Row | Mean | Median | Standard deviation | Adjusted mean | Count |
|---|---|---|---|---|---|
| High school | 5.16 | 5.10 | 0.985 | 5.16 | 104 |
| Postgraduate | 5.31 | 5.40 | 0.897 | 5.31 | 96 |
| Bachelor | 5.27 | 5.35 | 0.995 | 5.27 | 100 |
Covariate results
| Row | F statistic | p value | Partial eta squared |
|---|---|---|---|
| age | 1.65 | 0.201 | 0.006 |
Homogeneity of variance (Levene)
- p value
- 0.448
- Homogeneous
- Yes
Computation credits: scipy 1.18.0 · statsmodels 0.14.6 · scikit-learn 1.9.0 · numpy 2.5.1 · pandas 3.0.5 · semopy 2.3.11 · 89fc29a · Data seed: 20260914
How to report the result
With pre-test score entered as a covariate, training format had a significant effect on final test scores, F(2, 128) = 4.71, p = .011, partial η² = 0.07, with adjusted means of 68.7 for the in-person format, 70.4 for live online and 67.4 for self-paced (covariate effect F(1, 128) = 48.35, p < .001).
An example sentence close to APA style; the numbers are representative.
When you should not use it
- It returns no pairwise comparisons of adjusted means, so when the group effect is significant this output cannot tell you which formats differ.
- Homogeneity of regression slopes is not tested; with no group-by-covariate interaction in the model, the adjustment is biased if the slopes genuinely differ across groups.
- Levene's result does not alter the model. When variances are not homogeneous, no alternative estimation is used and only a note is recorded.
- Analysis of covariance is no substitute for random assignment. Where groups formed observationally, unmeasured differences stay in the model and adjusted means do not license a causal comparison.
- A covariate carrying measurement error under-adjusts, a margin worth remembering when the covariate is a single-item measure.
- Residual normality is not checked and no method-specific chart is produced, so the output offers nothing with which to eyeball the fit of the model.
What to use when the assumptions are not met
- One-Way ANOVAWhy: When there is no continuous variable to control for, or the covariate's effect turned out near zero, so the model need not carry the extra term.
- Two-Way ANOVAWhy: When the variable to control for is categorical rather than continuous; it enters as a second factor whose interaction can also be tested.
- Linear Regression (OLS)Why: When the number of covariates grows, or the question is the magnitude of the coefficients rather than the group difference; the same model reads in more detail in regression terms.
- Independent Samples t-TestWhy: When there are two groups and nothing needs controlling; it gives the mean difference together with an effect size.
Frequently asked questions
- Is homogeneity of regression slopes tested?
- It is not. The model the panel fits contains no interaction between group and covariate, so the output holds no test of whether the slopes diverge across groups. If you suspect this assumption, you can study the covariate-outcome relationship group by group, for instance by running a linear regression within each group and comparing the slopes. Where the slopes clearly differ, it is sounder to describe how the group difference varies with the level of the covariate than to compare a single pair of adjusted means.
- Levene's test was significant. Does the analysis change by itself?
- It does not. Levene's test runs by group on the raw dependent variable and its result is reported with a note, but the model is fitted identically either way. This differs from software that switches estimation method when homogeneity of variance fails, so when group sizes are unbalanced and the spreads clearly diverge, you need to interpret the result in light of that information.
- How many covariates can I add?
- The parameter form accepts one or several, and each covariate gets its own effect row in the output. Every extra term, though, costs error degrees of freedom, and adding covariates that correlate highly with one another makes the estimates unstable. A small number of covariates with theoretical backing produces firmer results than pouring every numeric column into the model.
- If the groups differed to begin with, does ANCOVA fix that?
- Only on the variable you put in the model, and only under the assumption of a linear relationship. Analysis of covariance is a statistical equating, not a replacement for random assignment: where groups formed on their own, every difference you did not measure stays outside the model, and a gap between adjusted means carries no causal claim. Controlling for a single variable such as a pre-test does not show that the groups are alike in other respects.
References
- Field, A. (2018). Discovering Statistics Using IBM SPSS Statistics
- Tabachnick, B. G., & Fidell, L. S. (2019). Using Multivariate Statistics
- Howell, D. C. (2013). Statistical Methods for Psychology
- statsmodels.formula.api.ols documentation
Try it with your own data
The free plan includes 50 analysis runs a month and needs no card.